sorting

Sort using only some columns

I have a 600MB tab delimited file that needs to be sorted using only the first two columns. Any lines already in order by those columns should remain in the existing order. My efforts using sort and --key seem to keep sorting the lines by the other columns. This is an example of the unsorted file: 1244072768 7234 Z 1244072768 7234 e...

How can I make an HTML table sortable with javascript without loading data via AJAX?

How can I make a table sortable using javascript without loading data via AJAX? More specifically, I'm looking for a solution that gives me the following: Works on a plain old HTML table Makes columns sortable using a natural comparison Is agnostic of server-side technology (should be portable regardless of whether the tables are bein...

Filter XSLT results

Hi there I have a questing about XSLT. I am making a website on Sitecore CMS, and some of the pages have to show a list of articles. That's not a problem. Every articlelist can be 'tagged' with one or more tags, and the same for every article. Let's say that I have an articlelist that have been tagged with 'Wordpress'. Then I only wan...

jQuery javascript custom sort procedure works in Firefox, but IE doesn't seem to get it... (copy-paste example code)

Hi, i've built this sample code based on a real problem I have in an application. I've got a custom sort procedure to sort jQuery arrays. A container contains a list of items with special attributes. For sorting: Loads all items in temp array Clears the container Sorts the temp array into a new array Append sorted items to containe...

Sorting an collecton of java beans by field

Hi, I have an collection of java beans that populate a JSF DataTable I'm trying to implement column sorting. I'd like to sort the array/collection depending on the field selected. I have using Reflection in the past for this, but wanted to find a neater way of doing it, using Commons BeanUtils and/or Collections but can't seem to find...

Dynamic Sort Criteria for Generic List

The purpose of this is to avoid writing a ton of if() statements. Here is my current code: public override List<oAccountSearchResults> SearchForAccounts(oAccountSearchCriteria searchOptions) { List<oAccountSearchResults> results = Service.SearchForAccounts(searchOptions); results.Sort((a1, a2) => a2.AccountNumber.CompareTo(a1.A...

Java Array sort: Quick way to get a sorted list of indices of an array

The problem: Consder the following floats[]: d[i] = 1.7 -0.3 2.1 0.5 What I want is an array of int[] that represents the order of the original array with indices. s[i] = 1 3 0 2 d[s[i]] = -0.3 0.5 1.7 2.1 Of course it could be done with a custom comparator, a sorted set of custom objects, or by simply sorti...

How to sort based on dependencies?

I have an class that has a list of "dependencies" pointing to other classes of the same base type. class Foo(Base): dependencies = [] class Bar(Base): dependencies = [Foo] class Baz(Base): dependencies = [Bar] I'd like to sort the instances these classes generate based on their dependencies. In my example I'd expect ins...

Most efficient sorting algorithm for a large set of numbers

I'm working on a large project, I won't bother to summarize it here, but this section of the project is to take a very large document of text (minimum of around 50,000 words (not unique)), and output each unique word in order of most used to least used (probably top three will be "a" "an" and "the"). My question is of course, what would...

What's wrong with Collections.sort?

I have these strings in an ArrayList of String in no particular order but when I invoke Collections.sort(listReference), the sorted result is incorrect, why do 10 and 11 (the last 2 characters) come before 07, 08, 09? 12880 20090506054200001 12880 20090506054200002 12880 20090513070200003 12880 20090513070200004 12880 2009052020260...

Converting the "arguments" object to an array in javascript

As a trivia question, I'm trying to write a javascript function that returns its variable number of arguments in sorted (normal lexicographic) order. Having never dealt with javascript before, I came across the "arguments" object, which seems to work somewhat like an array but without having the standard array functions -- therefore I s...

Which sorting algorithm is used in stl and .net base library default search?

I am now working on an imprived version of merge sort. I implemented it with C++ and C#. Then compared them with the stl sort and array.sort() algorithm respectively. In C++ I have got an equal (sometimes better) result. But in C#, I had to use unsafe code for using pointers. Here the performence is not that much comparable with default ...

sorting an arraylist of a self-made class by one of its variables and clone() will not work.

ok; i am making a project for school and its a game similar to falling sand. but in order for the gravity to work i have to have the sand sorted by its position from down to up (the y variable of sand) this method should sort it; although i cannot get .clone() to work and i can't hard copy any other way i know. so i don't know how to rep...

Is it correct to use JavaScript Array.sort() method for shuffling?

I was helping somebody out with his JavaScript code and my eyes were caught by a section that looked like that: function randOrd(){ return (Math.round(Math.random())-0.5); } coords.sort(randOrd); alert(coords); My first though was: hey, this can't possibly work! But then I did some experimenting and found that it indeed at least see...

Sorting a string that could contain either a time or distance

I have implemented a sorting algorithm for a custom string that represents either time or distance data for track & field events. Below is the format '10:03.00 - Either ten minutes and three seconds or 10 feet, three inches The result of the sort is that for field events, the longest throw or jump would be the first element while for ...

sorting differences

I am currently learning a number of different sorting algorithm. being curious with the differences,I tried to find the information of them but none is good enough. so here is my questions, in term of performance and their concept, what is the differences among bubble sort, selection sort, insertion sort, shell sort and quick sort. ...

WPF DataGrid sort by ComboBox field

I have WPF datagrid with combox column (ID is real value, Desc is displayed value) and when I click on header of that column automatically sorts by real value (ID). I want to sort by displayed value. My WPF datagrid has 4 columns: IdPerson, DescSchool, IdSchool and School. Column "School" is comboBox with this values:ItemSource = schoo...

C# List<> Order with 3 properties .Net 2.0

Hi, Say I have a Person class with Name, Age, Level properties. I know how to order by one of the properties, with PersonList.Sort(delegate(Person p1, Person p2) { return p1.Name.CompareTo(p2.Name); }); But how can I order by Name, Age and Level. An equivalente of the sql sentence : ORDER BY Name, Age, ...

Techniques for sorting up/down voted items

I'm pulling items from a database (in this case, comments, but it should apply to anything) and have the following information about them: The number of up votes The number of down votes (consequently, the total score and number of votes) The date the item was created I'm interested in coming up with a way to sort them with the followin...

Opencv sort sequences in python

I'm using the Python OpenCV bindings to find the contours in an Image. I'm know looking for the possibility to sort this sequence. It seems the usual python ways for list sorting don't apply here because of the linked list structure generated from OpenCV. Do you know a good way to sort the Contours by Size (Area/BoundingRectangle) i...