sorting

I want to rank document and store them in a list in python.

I am just a beginner in python. I have document score= {1:0.98876, 8:0.12245, 13:0.57689} which is stored in dictionary. The keys are corresponding to a series of document id and the values are corresponding to the score for each document id. How do I rank the document based on the scores? inverse=[(value, key) for key, value in score.i...

Sorting a MySQL query with ORDER BY or with PHP sort functions

Hi all, I have a query that I want to sort alphabetically, but the trick is that I want the sorting to treat two columns equally. For instance, if the first row of first_col equals apple and the second row of second_col equals aardvark I want the value in the second row of second_col to be listed before the value in the first row of fir...

Sorting nil-valued rows always to bottom in nstableview column

Hi there, I have an nstableview in my application containing several columns. When I click on one column header in order to have it sorted ascending, rows with a nil-value in that column are being sorted on top followed by non-nil-valued rows in ascending order. If I reclick on the same column, first the non-nil-valued rows are being sh...

sort large data in redis

how to sort large data in redis? ...

How to sort a list of inter-linked tuples?

lst = [(u'course', u'session'), (u'instructor', u'session'), (u'session', u'trainee'), (u'person', u'trainee'), (u'person', u'instructor'), (u'course', u'instructor')] I've above list of tuple, I need to sort it with following logic.... each tuple's 2nd element is dependent on 1st element, e.g. (course, session) -> session is dependent...

dot net gridview sorting problem

Dear All, I have a web application (with C#). I have a GridView and want to be able to sort its contents. I have added the tags ... AllowSorting="True" onsorting="MyGridView_Sorting"> and asp:BoundField DataField="NAME" HeaderText="Name" SortExpression="NAME" inside the GridView. I have implemented the MyGridView_Sorting method...

Sorting an array collection based on value of array in flex

Hey, I've been looking at sorting array collections. So far I've seen things like sorting numerically in ascending and descending order. What I'm looking for is to discover away to sort an arraycollection based on the order of values in another array. For Example: I have an array containing 10 numerical values. I also have an arraycol...

how to sort a string array by alphabet?

Hi, i've got a array of many strings. How can I sort the strings by alphabet? ...

jQuery table sort with colspan or rowspan

Hi I'm using tablesorter and have problems with sorting tables that contain rowspan in definition. I've read hints here http://stackoverflow.com/questions/2509690 but solution doesn't work when I have different values for rowspan: once is rowspan=3, once 4 - depends on data taken from DB. Do you have any other plugin that sorts even s...

Sort a vector on a value calculated on each element, without performing the calculation multiple times per element

Hi chaps, can anyone recommend a nice and tidy way to achieve this: float CalculateGoodness(const Thing& thing); void SortThings(std::vector<Thing>& things) { // sort 'things' on value returned from CalculateGoodness, without calling CalculateGoodness more than 'things.size()' times } Clearly I could use std::sort with a comparis...

sorting NSMutableArray weird results with Core Data

Hi all, I have been going over this for hours and cannot find the problem. I have an array of scores which I save at the end of a game in a core data model. After saving when I go back into the high scores viewcontroller I load the scores from core data and sort the array using the following function where scores array is an NSMutableA...

do you have to sort rows of a sparse matrix when doing a PCG solver?

I am working on some software that does a sparse matrix-vector multiply. The matrix is stored in a coordinate format (a row and column index for each non-zero). They are performing a sort operation that sorts the column index in order for that row (that is because of some boundary conditions for this FEM problem). Is there some necessit...

JavaScript - Sort SELECT options

Using PHP, I scan a directory and list all of the .xml files. Each XML file contains both a "name" element and a "date" element. The "name" element for each XML file is listed as an option in the select list. This works perfectly fine, however, the "date" element in each XML file is different and contains a date format like this: mm/dd...

Sort an array of hashes by a value in the hash

Hello, this code is not behaving as I would expect: # create an array of hashes sort_me = [] sort_me.push({"value"=>1, "name"=>"a"}) sort_me.push({"value"=>3, "name"=>"c"}) sort_me.push({"value"=>2, "name"=>"b"}) # sort sort_me.sort_by { |k| k["value"]} # same order as above! puts sort_me I'm looking to sort the array of hashes by ...

Help sorting XML Data in .NET (maybe with LINQ query?)

I have this hierarchy of XML <Chapters> <Chapter @num=""> <Section @letter=""> <Heading @num="" /> </Section> </Chapter> </Chapters> I need to do a sort so that all chapters are sequenced in ascending order, each section within that chapter is sequenced in ascending order, and each heading in that section is sor...

Merge two sorted parts of an array with constant memory in O(n) time

Hi! Assume we have an array of length N where the subarrays from 0 to N/2 and N/2 to N elements are sorted. Is it possible to sort the whole array using constant memory in O(N) time? Example of an array: 10, 20, 30, 40, 1, 2, 35, 60 ...

Converting XML files to be human-editable and managable by VCS

Sometimes XML files needs to be stored in some VCS. Such files are often edited using GUI tools which can reorder the elements each times as they want. Also VCS merging is usually line-oriented, and often XML files either looks likes one long line or fully indented like <foo> <bar> <name> n3 </name> ...

Sorting Long integers with Java TableRowSorter

I'm have a table that handles large numbers, and I want it to be sorted. The table has no problem displaying the numbers, but TableRowSorter seems to treat the numbers as Integers, thus sorting large values incorrectly when they exceed the maximum Integer value. How can I use TableRowSorter to sort Longs? ...

Sort BST in O(n) using constant memory

This is not a homework. Just an interesting task :) Given a complete binary search three represensted by array. Sort the array in O(n) using constant memory. Example: Tree: 8 / \ 4 12 /\ / \ 2 6 10 14 /\ /\ /\ /\ 1 3 5 7 9 11 13 15 Array:...

Sort C++ Strings with multiple criteria

I need to sort a C++ std::vector<std::string> fileNames. The fileNames are labeled as such YYDDDTTTT_Z_SITE YY = Year (i.e 2009 = 09, 2010 = 10) DDD = Day of the year (i.e 1 January = 001, 31 December = 365) TTTT = Time of the day (i.e midnight = 0000, noon = 1200) ZONE = Will be either E or W SITE = Four letter site n...