sorting

Django menu item sorting

Hi i've got MenuItem model : MenuItem(models.Model) name=models.CharField(max_length=50) url = models.URLField() position = models.IntegerField() Class Meta: ordering =['position'] then i'm retriving it by MenuItem.objects.all() My question is how can i make any user friendly interface in admin panel to allow sorting MenuIte...

Get the largest value from Json object with Javascript

Hi This should be an easy one. I just cant figure it out. How do I get the largest value from this piece of JSON with javascript. {"data":{"one":21,"two":35,"three":24,"four":2,"five":18},"meta":{"title":"Happy with the service"}} The key and value I need is: "two":35 as it is the highest thanks ...

Sorting a text file by date - Date looks like DD/MM/YYYY

I am trying to sort the dates from the earliest to the latest. I was thinking about using the bufferedreader and do a try searching the first 2 characters of the string and then the 4th and 5th characters and finally the 7th and 8th characters, ignoring the slashes. The following is an example of the text file I have: 04/24/2010 - 200...

Gridview SortExpression with 2 fields

Hello, I have a GridView that get's its datasource from a complex object. So I'm doing the Sorting & Paging in the code behind. <asp:GridView ID="SystemsDetailList" runat="server" AllowSorting="true" AllowPaging="true" AutoGenerateColumns="False" ShowFooter="True" OnPageIndexChanging="gridView_PageIndexChanging" OnSorting="gridView_Sort...

Extracting a given number of the highest values in a List

I'm seeking to display a fixed number of items on a web page according to their respective weight (represented by an Integer). The List where these items are found can be of virtually any size. The first solution that comes to mind is to do a Collections.sort() and to get the items one by one by going through the List. Is there a more e...

Scala: how can I sort an array of tuples by their second element?

Hi all, is there a way in Scala to sort an array of tuples using and arbitrary comparison function? In particular I need to sort and array of tuples by their second element, but I wanted to know a general technique to sort arrays of tuples. Thanks! ...

C/GCC - Is it possible to sort arrays using preprocessor? [SOLVED]

I have a number of very long arrays. No run-time sort is possible. It is also time consuming to sort them manually. Moreover, new elements can be added in any order later, so I would like to sort them by value using C preprocessor or maybe there is any compilers flag (GCC)? For example: sometype S[] = { {somevals, "BOB", someotherva...

Exclude one or more elements from being connected (using connectWith) in jQuery's sortable lists

I have two lists, one with an ID of "vlist" and one with an ID of "hlist". The "vlist" holds elements which should be visible, while the "hlist" holds items that should remain hidden. The idea here is to allow the administrator of the system to specify which elements/fields should be shown on a sign-up page, and which shouldn't. The two ...

python: sorting

hi im doing a loop so i could get dict of data, but since its a dict it's sorting alphabetical and not as i push it trought the loop ... is it possible to somehow turn off alphabetical sorting? here is how do i do that data = {} for item in container: data[item] = {} ... for key, val in item_container.iteritems(): ... d...

Sorting By Multiple Conditions in Ruby

I have a collection of Post objects and I want to be able to sort them based on these conditions: First, by category (news, events, labs, portfolio, etc.) Then by date, if date, or by position, if a specific index was set for it Some posts will have dates (news and events), others will have explicit positions (labs, and portfolio). ...

Understanding ruby array sort

I am having a problem understanding how array.sort{|x,y| block} works exactly,hence how to use it? ruby-doc example: a = [ "d", "a", "e", "c", "b" ] a.sort #=> ["a", "b", "c", "d", "e"] a.sort {|x,y| y <=> x } #=> ["e", "d", "c", "b", "a"] thanks ...

How to drag items between 2 sorted lists with jQuery?

Hi - I'm trying to implement drag/drop/sort between 2 list elements: <ul id="first"> <li>item 1</li> <li>item 2</li> <li>item 3</li> </ul> <ul id="second"> <li>item 4</li> <li>item 5</li> <li>item 6</li> </ul> Basically I just want to be able to pass items between the lists and sort the items in each list. What's the simp...

How to sort search results in lucene?

For example, if I have enumeration with "good", "better", "the best" values, I want to sort my search results by field that holds one of this values in string representation. I have few purposes: 1) Create CustomAnalyzer that produces numeric value from enum: good -> 1, better -> 2, the best -> 3 2) Implement FieldComparator (I don't ...

How do I sort a multidimensional hash array by a key maybe three levels in, in PHP?

I am moving from Perl to PHP and am struggling to get my head around PHP sorting. Here's what I have in Perl: $log{'11111'}{'1'}{'20100102'}{'name'}='blah'; $log{'11111'}{'1'}{'20100101'}{'name'}='blah'; $log{'11111'}{'1'}{'20100103'}{'name'}='blah'; $cook='11111'; foreach $entry (sort {$log{$cook}{$a}{time} cmp $log{$cook}{$b}{time}...

std::list or std::multimap

Hey, I right now have a list of a struct that I made, I sort this list everytime I add a new object, using the std::list sort method. I want to know what would be faster, using a std::multimap for this or std::list, since I'm iterating the whole list every frame (I am making a game). I would like to hear your opinion, for what should I ...

Sorting an array in descending order in Ruby.

Hi, I have an array of hashes like following [ { :foo => 'foo', :bar => 2 }, { :foo => 'foo', :bar => 3 }, { :foo => 'foo', :bar => 5 }, ] I am trying to sort above array in descending order according to the value of :bar in each hash. I am using sort_by like following to sort above array. a.sort_by { |h| h[:bar] } However ...

Sorting Scientific Number With Unix Sort

I tried to sort these number with Unix sort, but it doesn't seem to work: 2e-13 1e-91 2e-13 1e-104 3e-19 9e-99 This is my command: sort -nr file.txt What's the right way to do it? ...

PHP splitting arrays into groups based on one field's value

I have an array containing arrays of names and other details, in alphabetical order. Each array includes the first letter associated with the name. Array ( [0] => Array ( [0] => a [1] => Alanis Morissette ) [1] => Array ( [0] => a [1] => Alesha Dixon ...

Resharper plugin to sort the methods alphabetically?

Does something like that exist? ...

How to sort an NSMutableArray List of names in alphabetical order in objcetive -c?

Hi Guys, I need to display the list of names which are getting from the parser. I am getting the nsmutable arrary of list, then i need to display them in alphabetical order please provide solution. Thank you, Madan Mohan. I tried which you have given NSArray *myArtistArray=[[NSArray alloc]init]; myArtistArray=[artistsList sort...