sorting

Sort collection of object in rails ?

I know I can use something like User.sort {|a, b| a.attribute <=> b.attribute} or User.find and order, but is it a way like comparable interface in Java, so every time I called sort on User object it will do sort on the predefined attributes. Thanks, ...

LINQ to SQL Dynamic Sort question

How do I code the Select clause in my LINQ satament to select column aliases so I can sort on them basically I want to accomplish this SQL statement in LINQ: select type_id as id, type_desc as description from dbo.equip_type_avt order by description What do I replace the ????? in my .Select clause in my LINQ stat...

Java Array Sort descending?

Is there any EASY way to sort an array in descending order like how they have a sort in ascending order in the Arrays class http://www.j2ee.me/javase/6/docs/api/java/util/Arrays.html ? Or do I have to stop being lazy and do this myself :[ ...

XSLT Apply sort to second value if first is empty

I have a for each which loops round news item nodes. Among other properties these news items have two attributes for created date. System added date and a user entered created date (to override the system date). I would like the list sorted by created date with the preference on the user entered date. Below is my humble invalid attempt!...

Sort not compatible with IE?

The code below works fine for dynamically reordering links in firefox, but for some reason not in IE (version 7). Any ideas what part of the code is causing problems? Thanks. var parent = $('#itemHolder'); var children = $('a', parent); var children = $('a', parent).sort(function(a, b) { return parseInt($(b).attr('amount')) ...

How to implement efficient sorting algorithms for multiple processors with Scala?

How to implement efficient sorting algorithms for multiple processors in Scala? Here's the link for radix algorithm in GPU: radix algorithm in GPU ...

Parsing Text Files and Sorting in Ruby

I am somewhat new to Ruby and I would appreciate some direction in solving the problem which I will now describe. I would like to write a Ruby program which can parse 3 separate text files each of which contain different delimiters and then sort them according to certain criteria. Can someone please point me in the right direction? ...

How to apply default sorting in lucene on equal scores?

Good day, If I have for example the documents which have the following fields Person_name - Birthday Jordan - 2009-06-15 Marc - 2009-01-01 Marcos - 2009-01-01 Marcissh_something_something - 2009-06-15 Marcos - 2009-12-31 And upon searching for Person_name:Marc* I got the following scores (scores here are hypothetical) Person_name - ...

MySQL: Sorting a Row, Then Sorting the Columns?

If I have 3 columns, X, Y, Z, that are each a number, how can I get each row returned greatest to least, and then the rows return greatest to least? So if I had: X Y Z 8 7 9 1 2 3 4 6 5 how could I get: 9 8 7 6 5 4 3 2 1 ...

Can I Nest OrderBy in .NET?

This doesn't seem to work as I intend. VB.NET: Dim x = Model.Discussions.OrderByDescending(Function(d) d.Messages.OrderByDescending(Function(m) m.Sent).First.Sent) For Each d As Discussion In x ... Next I get this runtime error: Sequence contains no elements There should be 20. Discussions are collections of messages. I w...

Drag and drop sorting of table columns with jQuery

I'm using jQuery to drive my AJAX UI. I have a table of data, and I want to allow the user to reorder the columns in the table by dragging and dropping them. I'd like the user to be able to grab the header for a column and move it. The row of data underneath should follow. Note that I'm not interested in sorting the data or in reordering...

Problem with sorting on child object in Hibernate when order-by is present in .hbm files ?

Hi, I am using Hibernate3.jar in our App.While trying to fetch some objects using the foreign key we used the order-by clause on the collection as shown below < set name="children" cascade="all-delete-orphan" lazy="true" order-by="SORT_ORDER_ID asc,lower(CHILD_NAME) asc,lower(FIRST_NAME) asc,lower(LAST_NAME) asc"> Now i ...

How can I sort a coordinate list for a rectangle counterclockwise?

I need to sort a coordinate list for a rectangle counterclockwise, and make the north-east corner the first coordinate. These are geographic coordinates (i.e. Longitude, Latitude) in decimal form.1 For example, here are the 4 corners of a rectangle, starting with the north-west corner and moving clockwise: [ { "lat": 34.495239, "lng"...

WPF Keep column sorting with Datagrid

Hi, I have several datagrid where I need to update the informations. Things is, since more than one person works on the system at the same time, the datagrid need to be refreshed on a regular basis. When I refresh, I lose the sorting that user had. Is there a way to keep it? thanks ...

Pl/SQL: How to sort a table of records?

I'm new to pl/sql ! I'm trying to sort a table of records, using a simple bubble-sort algorithm. What is the problem? Where could I find more information about using table of records ? DECLARE text VARCHAR2(50); TYPE TIP_VECTOR IS TABLE OF INT INDEX BY BINARY_INTEGER; TYPE contorRecord IS record ( codASCII VARCHAR2...

Using jquery do sorting in gridview of .net?

Need Example of jquery for sorting... ? ...

Sorting SQL by first two characters of fields

I'm trying to sort some data by sales person initials, and the sales rep field is 3 chars long, and is Firstname, Lastname and Account type. So, Bob Smith would be BS* and I just need to sort by the first two characters. How can I pull all data for a certain rep, where the first two characters of the field equals BS? ...

sort vector by more than 1 field

How do I sort the below code by name, age and score... all three fields #include <string> #include <vector> #include <algorithm> struct student_t { std::string name; int age, score; }; bool by_more_than_1_field( student_t const &lhs, student_t const &rhs ) { // sort by name, age and score } int main() { ...

Which sorting algorithm is used by STL's list::sort()?

I have a list of random integers. I'm wondering which algorithm is used by the list::sort() method. E.g. in the following code: list<int> mylist; // ..insert a million values mylist.sort(); EDIT: See also this more specific question. ...

Which sorting algorithm is used by Microsoft's STL::list::sort()?

Note: I accidentally posted this question without specifying which STL implementation I was using, and I felt it can't really be updated since it would render most of its answers obsolete. So, the correct question goes - which sorting algorithm is used in the below code, assuming I'm using the STL library of Microsoft Visual C++?: list...