sorting

Django annotate on a "custom field" with django-sorting

Hello, I have to show entries by date in a django app and i'm a bit blocked : Here's an example of my models: class Event(models.Model): name = models.CharField(max_length=100) theme = models.ForeignKey(Theme) ... class Date(models.Model): event = models.ForeignKey(Event) start = models.DateField() en...

Sorting a NSArray

Hi, I have a NSArray of objects. Those objects have an int attribute called "distance". I would like to sort my array by distance. Could someone please tell me how to do that ? I can't understand how the sortUsingSelector or sortUsingDescriptor methods are working... Thanks ...

I need to sort the facets that come back from SOLR by relevancy

I have within my SOLR index song objects which belong to a higher level album object. An example is shown below: <song> <album title>Blood Sugar Sex Magic</album title> <song title>Under the Bridge</song title> <description>A sad song about junkies</description> </song> What I can do at the moment is create a facet on the album title ...

Silverlight 4 Datagrid Sorting

I'm having a heck of a time trying to get a silverlight datagrid to properly sort, and do so quickly (sub 1/10 second). Here's the scenario: -WCF callback every 1/5 of a second -Take the callback, match up to the existing record in an ObservableCollection -Update the ObservableCollection's properties -Bind the grid. I've tried a linq ...

How do I sort a Perl hash that has tons of data?

I am sorting a hash in Perl. I encountered an Out of memory error when running my Perl Script: foreach $key (sort (keys(%hash))) { .... } How do I sort a hash that has tons of data? ...

sorting array after array_count_values

hi to all! I have an array of products $products = array_count_values($products); now I have an array where $key is product number and $value is how many times I have such a product in the array. I want to sort this new array that product with the least "duplicates" are on the first place, but what ever I use (rsort, krsort,..) i loo...

Sort a list with element still in first position

I have a String list: List<String> listString = new ArrayList<String>(); listString.add("faq"); listString.add("general"); listString.add("contact"); I do some processing on the list and I want to sort this list but I want "general" to always end up in first position. Thx ;) ...

Disallow button press feedback in non-sortable WPF ListView header

For a WPF ListView bound to an simple list that has no need or support for sorting, how you do make it so that the user doesn't get button press feedback when he clicks on a header? By default, clicking the middle of a column header feels like a button press for which nothing happens. An example of the look and feel I'm trying to achiev...

bidirectional bubble sort

Here is the code for shacker sort or bidirectional bubble sort. Something is wrong. Error is java.lang.ArrayIndexOutOfBoundsException Can anybody help me? public class bidirectional{ public static void main(String[]args){ int x[]=new int[]{12,9,4,99,120,1,3,10}; int j; int n=x.length; int st=-1; while (st<...

effective functional sort

I'm programming a function for a TI-NSpire, so I can't use the builtins from inside a function. What is the most generally efficient algorithm for sorting a list of numbers without modifying the list itself? (recursion and list-splitting are fair game, as is general use of math.) ...

getting userbase vote average and individual user's vote in the same query?

Here goes: T1 [id] [desc] 1 lovely 2 ugly 3 slender T2 [id] [userid] [vote] 1 1 3 1 2 5 1 3 2 2 1 1 2 2 4 2 3 4 In one query (if possible) I'd like to return: T1.id, T1.desc, AVG(T2.vote), T2.vote (for user viewing the page) I can get the first 3 i...

Implement sort similar to radix

hi i need to write sucj kind of sorting maybe it is similary to radix sort and also (this is not homework because i created it problem myself and please if anobody can help me) problem is like this suppose i have array int x[]=new int[]{4,5,3,2,1}; let write it into binary form 5 -0101 4- 0100 3-0011 2-0010 1-0001 i want to sort...

Alternatives to sign() in sqlite for custom order by

I have a string column which contains some numeric fields, but a lot are 0, empty string or null. The rest are numbers having different range, all positive. I tried to create a custom order by. The order would be done by two fields. First I would like to order the fields that have this number >0 and then sort by name. So something this...

ruby sortby 3rd element in a multidimential array npot working properly

Hi, I'm using ruby to sort an array where each element in the array is another array. I have this: Data = Data.SortBy { |Info| info[3] } example data in this column: 3.1 2 5.65 -1 0.4 -9.43 -10.87 -2.3 It should sort this into: 5.65 3.1 2 0.4 -1 -2.3 -9.43 -10.87 But it comes out like this: 5.65 3.1 2 0.4 -1 -10.87 -2.3 -9.43...

LINQ OrderBy: best search results at top of results list

Consider the need to search a list of Customer by both first and last names. The desire is to have the results list sorted by the Customer with the most matches in the search terms. FirstName LastName ---------- --------- Foo Laurie Bar Jackson Jackson Bro Laurie Foo Jackson Laurie ...

Sorting an array of structs

I have an array of structs called leaders. The struct class looks like this, for contextual info: class Leader < Struct.new(:rank, :user); end Two questions: How do I sort the array of structs by rank? How do I sort the array of structs by rank and by user.created_at? ...

Ajax loaded content , jquery plugins not working

Hello, I have a link that calls the ajax to load content, and after the content is loaded, my jquery function doesn't work anymore Here is my HTML <a href="#" onclick="javascript:makeRequest('content.html','');">Load Content</a> <span id="result"> <table id="myTable" valign="top" class="tablesorter"> <thead> <...

Problem understanding treesort in Haskell

I am trying to figure out how exactly does treesort from here work (I understand flatten, insert and foldr). I suppose what's being done in treesort is applying insert for each element on the list thus generating a tree and then flattening it. The only problem I can't overcome here is where the list (that is the argument of the function...

Combining entries, filtering of Python dictionaries

I have two large lists that are filled with dictionaries. I need to combine the entries if a value from dict2==dict1 and place the newly combined matches somewhere else. I'm having trouble explaining it. List one contains: {'keyword':value, 'keyword2':value2} List two: {'keyword2':value2, 'keyword3':value3} I want a new list with ...

In XSLT, how can you sort using an indirect key?

I am having trouble getting xsl:sort to understand the scope of the attributes I am referencing. Here is an XML sample document to illustrate: <Root> <DrinkSelections> <Drink id=1000 name="Coffee"/> <Drink id=1001 name="Water"/> <Drink id=1002 name="Tea"/> <Drink id=1003 name="Almost But Not Quite Entirely Unlike Tea"/...