Search Results

Search found 772 results on 31 pages for 'ordering'.

Page 1/31 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Scala 2.8 TreeMap and custom Ordering

    - by Dave
    I'm switching from scala 2.7 and ordered to scala 2.8 and using ordering. It looks quite straight forward but I was wondering could I make it a little less verbose. For example: scala> case class A(i: Int) defined class A scala> object A extends Ordering[A] { def compare(o1: A, o2: A) = o1.i - o2.i} defined module A If I then try to create a TreeMap I get an error scala> new collection.immutable.TreeMap[A, String]() <console>:10: error: could not find implicit value for parameter ordering: Ordering[A] new collection.immutable.TreeMap[A, String]() ^ However if I explicitly specify the object A as the ordering it works fine. scala> new collection.immutable.TreeMap[A, String]()(A) res34: scala.collection.immutable.TreeMap[A,String] = Map() Do I always have to explicitly specify the ordering or is there a shorter format? Thanks

    Read the article

  • google collections ordering on map values

    - by chris-gr
    I would like to order a map based on the values. Function<Map.Entry<A, Double>, Double> getSimFunction = new Function<Map.Entry<A, Double>, Double>() { public Double apply(Map.Entry<A, Double> entry) { return entry.getValue(); } }; final Ordering<Map.Entry<A, Double>> entryOrdering = Ordering.natural().onResultOf(getSimFunction); ImmutableSortedMap.orderedBy(entryOrdering).putAll(....).build(); How can I create a new sortedMap based on the ordering results or a sortedset based on the map.keyset()?

    Read the article

  • Ordering columns in Rails, cakephp style.

    - by Smickie
    CakePHP's built in pagination helpers automatically allow column ordering in the view. If you bake the view you get a link on each column to order it by that data. Is there a way to get this functionality in Rails? The standard will paginate doesn't offer it, anyone know any good ones?

    Read the article

  • Complicated football league Dynamic Ordering in MySQL?

    - by Dan
    I have a table 'games' for a football league as follows: date home_team_id away_team_id home_score away_score - 1 2 6 21 - 3 1 7 19 I can't figure out how to dynamically generate a list of team ID's ordered by Wins (then points for if poss)? -- I have this query which works fine when I have a $team_id but of cause then I can only do 1 team at a time, and that doesn't allow for ordering at query level ((SELECT COUNT(*) FROM `games` WHERE ((`home_score` > `away_score`) AND `home_team_id` = '.$team_id.')) + (SELECT COUNT(*) FROM `games` WHERE ((`home_score` < `away_score`) AND `away_team_id` = '.$team_id.'))) AS `wins` I wonder if i can use this with some form of GROUP, or mySQL can know the $team_id itself? I've also tried some multiple JOINs with the 'team' table but they didn't work either. Thanks, Dan

    Read the article

  • Ordering .each results in the view...

    - by bgadoci
    I am wondering if it is possible to dictate the order (i.e. :order = 'created_at DESC') within the view. I realize that logic in the view is not ideal but I seem to be having some problems locating where to affect this output. For instance, here is my code: <% @user.questions.each do |question| %> <%= link_to_unless_current h (question.title), question %> Created about <%= time_ago_in_words h(question.created_at) %> ago Updated about <%= time_ago_in_words h(question.updated_at) %> ago <%= link_to 'Edit', edit_question_path(question) %> | <%= link_to 'Destroy', question, :confirm => 'Are you sure?', :method => :delete %> <% end %> In my QuestionsController I have the following index action but it is not affecting the output from the code above. class QuestionsController < ApplicationController def index @questions = Question.all(:order => 'created_at DESC', :limit => 20) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @questions } end end end

    Read the article

  • LINQ and ordering of the result set

    - by vik20000in
    After filtering and retrieving the records most of the time (if not always) we have to sort the record in certain order. The sort order is very important for displaying records or major calculations. In LINQ for sorting data the order keyword is used. With the help of the order keyword we can decide on the ordering of the result set that is retrieved after the query.  Below is an simple example of the order keyword in LINQ.     string[] words = { "cherry", "apple", "blueberry" };     var sortedWords =         from word in words         orderby word         select word; Here we are ordering the data retrieved based on the string ordering. If required the order can also be made on any of the property of the individual like the length of the string.     var sortedWords =         from word in words         orderby word.Length         select word; You can also make the order descending or ascending by adding the keyword after the parameter.     var sortedWords =         from word in words         orderby word descending         select word; But the best part of the order clause is that instead of just passing a field you can also pass the order clause an instance of any class that implements IComparer interface. The IComparer interface holds a method Compare that Has to be implemented. In that method we can write any logic whatsoever for the comparision. In the below example we are making a string comparison by ignoring the case. string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "cHeRry"}; var sortedWords = words.OrderBy(a => a, new CaseInsensitiveComparer());  public class CaseInsensitiveComparer : IComparer<string> {     public int Compare(string x, string y)     {         return string.Compare(x, y, StringComparison.OrdinalIgnoreCase);     } }  But while sorting the data many a times we want to provide more than one sort so that data is sorted based on more than one condition. This can be achieved by proving the next order followed by a comma.     var sortedWords =         from word in words         orderby word , word.length         select word; We can also use the reverse() method to reverse the full order of the result set.     var sortedWords =         from word in words         select word.Reverse();                                 Vikram

    Read the article

  • POP Culture

    - by [email protected]
    When we hear the word POP, we normally think of a soft drink, or a soda, while for others, it might be their favourite kind of music. In my case, it's the sound my knee makes when I bend down. Within Oracle though, when we talk about POP, we are referring to the Partner Ordering Portal. The Partner Ordering Portal, or POP as we like to call it, provides AutoVue Partners with a method to submit their orders online. POP offers Partners with up-to-date pricing and licensing information, efficient order processing, as most data is validated on screen, thereby reducing errors and enabling faster processing and, online order status and tracking. POP is not yet available in every country, but it is available in most. Click here to check out the POP home page (OPN Login information required) to see if your country of business is eligible to use POP and, for access to creating an account, watching instructional training viewlets, etc.

    Read the article

  • SharePoint: UI for ordering list items

    - by svdoever
    SharePoint list items have in the the base Item template a field named Order. This field is not shown by default. SharePoint 2007, 2010 and 2013 have a possibility to specify the order in a UI, using the _layouts page: {SiteUrl}/_layouts/Reorder.aspx?List={ListId} In SharePoint 2010 and 2013 it is possible to add a custom action to a list. It is possible to add a custom action to order list items as follows (SharePoint 2010 description): Open SharePoint Designer 2010 Navigate to a list Select Custom Actions > List Item Menu Fill in the dialog box: Open List Settings > Advanced Settings > Content Types, and set Allow management of content types to No  On List Settings select Column Ordering This results in the following UI in the browser: Selecting the custom Order Items action (under List Tools > Items) results in: You can change your custom action in SharePoint designer. On the list screen in the bottom right corner you can find the custom action: We now need to modify the view to include the order by adding the Order field to the view, and sorting on the Order field. Problem is that the Order field is hidden. It is possible to modify the schema of the Order field to set the Hidden attribute to FALSE. If we don’t want to write code to do it and still get the required result it is also possible to modify the view through SharePoint Designer: Modify the code of the view: This results in: Note that if you change the view through the web UI these changes are partly lost. If this is a problem modify the Order field schema for the list.

    Read the article

  • Ensuring a repeatable directory ordering in linux

    - by Paul Biggar
    I run a hosted continuous integration company, and we run our customers' code on Linux. Each time we run the code, we run it in a separate virtual machine. A frequent problem that arises is that a customer's tests will sometimes fail because of the directory ordering of their code checked out on the VM. Let me go into more detail. On OSX, the HFS+ file system ensures that directories are always traversed in the same order. Programmers who use OSX assume that if it works on their machine, it must work everywhere. But it often doesn't work on Linux, because linux file systems do not offer ordering guarantees when traversing directories. As an example, consider there are 2 files, a.rb, b.rb. a.rb defines MyObject, and b.rb uses MyObject. If a.rb is loaded first, everything will work. If b.rb is loaded first, it will try to access an undefined variable MyObject, and fail. But worse than this, is that it doesn't always just fail. Because the file system ordering on Linux is not ordered, it will be a different order on different machines. This is worse because sometimes the tests pass, and sometimes they fail. This is the worst possible result. So my question is, is there a way to make file system ordering repeatable. Some flag to ext4 perhaps, that says it will always traverse directories in some order? Or maybe a different file system that has this guarantee?

    Read the article

  • PostGres Error When Using Distinct : postgres ERROR: could not identify an ordering operator for ty

    - by CaffeineIV
    ** EDIT ** Nevermind, just needed to take out the parens... I get this error: ERROR: could not identify an ordering operator for type record when trying to use DISTINCT Here's the query: select DISTINCT(g.fielda, g.fieldb, r.type) from fields g LEFT JOIN types r ON g.id = r.id; And the errors: ERROR: could not identify an ordering operator for type record HINT: Use an explicit ordering operator or modify the query. ********** Error ********** ERROR: could not identify an ordering operator for type record SQL state: 42883 Hint: Use an explicit ordering operator or modify the query.

    Read the article

  • Methods of ordering function definitions in code

    - by xralf
    When I work on some programming project (usually command line application in Python with many switches), I'm usually creating about 30 and more functions. Most of the functions are in one file (except some helpers that I utilize in more projects). Some of the functions are called on particular switch (like -p or --print) but many functions do some helper computations, print operations or database operations because I don't want to main functions be too large. When I have an idea for a new functionality I often put new functions randomly to the file. Should I think more about it and place it to some particular place? Are there some methods for this?

    Read the article

  • Control vertical source ordering with 960.gs?

    - by Ztyx
    Hi, I've understood it's possible to control the vertical (columnwise) source ordering with the 960 Grid System. However, is it possible to do something similar vertically? If not, does anyone know of any grid system that handles source ordering vertically? Thanks, Jens

    Read the article

  • Chrome Tab Ordering?

    - by Mark
    If I'm on the first tab, and I hit Ctrl+T, I want it to open next to (to the right of) the current tab. Is there an extension for this? I think I want to change the closed tab ordering too... but I can never remember how I like it until I play with it. I think move to the left tab is what I like. TabMixPlus gives me these options in FF, is there a similar extension available yet? Or some hidden options in Chrome?

    Read the article

  • Ordering by a max or a min from another table

    - by Paul Tomblin
    I have a table that consists of a unique id, and a few other attributes. It holds "schedules". Then I have another table that holds a list of all the times each schedule has or will "fire". This isn't the exact schema, but it's close: create table schedule ( id varchar(40) primary key, attr1 int, attr2 varchar(20) ); create table schedule_times ( id varchar(40) foreign key schedule(id), fire_date date ); I want to query the schedule table, getting the attributes and the next and previous fire_dates, in Java, sometimes ordering on one of the attributes, but sometimes ordering on either previous fire_date or the next fire_date. Ordering by the attributes is easy, I just stick an "order by" into the string while I'm building my prepared statement. I'm not even sure how to go about selecting the last fire_date and the next one in a single query - I know that I can find the next fire_date for a given id by doing a SELECT min(fire_date) FROM schedule_times WHERE id = ? AND fire_date > sysdate; and the similar thing for previous fire_date using max() and fire_date < sysdate. I'm just drawing a blank on how to incorporate that into a single select from the schedule so I can get both next and previous fire_date in one shot, and also how to order by either of those attributes.

    Read the article

  • SEO, ordering and duplication of content

    - by piquadrat
    I run a specialized news site and am trying to apply a little bit of SEO sauce to it. One of the most important things I hear is to avoid duplication of content. I've covered all the basics but I'm stuck with ordering of content. As an example, the archive of the site is orderable by date, views, and rating. Since we don't have that many news items, an archive page for a particular day has usually only a couple of items, so the following URLs all have the same content, albeit in different ordering: /news/archive/2010/05/16/ /news/archive/2010/05/16/?o=views /news/archive/2010/05/16/?o=rating Do search machines penalize this particular kind of duplication of content? And if yes, what's the best way to avoid said penalty? <link rel="canonical" />? Tell Google & Co. to ingore the o parameter? Marking the ordering links with nofollow? Only allow the indexation of the date-ordered archive sites through robots.txt (not sure if this is even possible)?

    Read the article

  • Java EE 6 - ordering Servlet Request Listeners

    - by Walter White
    Hi all, I finally updated to Java EE 6 (web profile) and would like to control the ordering of my servlet request listeners. I did that before through the XML ordering by listing the listeners in a particular order. Now, I have placed the @WebListener annotation on the classes which are listeners and am trying to figure out how to order the listeners such that they work properly. One must run before another one, otherwise, it won't have the information it needs and won't work. Also, it doesn't seem my listeners are actually being invoked even though they're marked with @WebListener. I am running embedded glassfish 3.0. Another question that is somewhat related - ServletRequestListeners in Java EE 6 by default are still synchronous meaning they're hit first, then servlet filters, right? ServletRequestListeners are not asynchronous where they merely get notified of an event without interrupting the execution? Walter

    Read the article

  • django-haystack ordering - How do I handle this?

    - by Bartek
    Hi there, I'm using django-haystack for a search page on my site. I'm basically done, but not quite happy with the ordering and not quite sure how haystack decides how to order everything. I know I can over-ride the SearchQuerySet by using order_by but that over-rides it entirely. Let's say I want to force the search to order by in stock (BooleanField), so that the products that are in stock show up on top, but then do everything else as it normally would. How do I do that? I tried doing order_by('-in_stock', 'content') figure content was what it used by default but it produces very different results from if I just leave it to do its own ordering. Thanks for any input on this matter!

    Read the article

  • st-ordering library function?

    - by chang
    I'm in the search for an implementation of an ear-decomposition algorithm (http://www.ics.uci.edu/~eppstein/junkyard/euler/ear.html). I examined networkx and didn't find one. Although the algorithm layout is vaguely in my mind, I'd like to see some reference implementation, too. Side problem: First step could be an st-ordering of a graph. Are there any implementations for st-ordering algorithms you know? Thanks for your input. I'd really like to contribute e.g. to networkx by implementing the ear-decomposition algorithm in python.

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >