sorting

Extension method using Reflection to Sort

I implemented an extension "MyExtensionSortMethod" to sort collections (IEnumerate). This allows me to replace code such as 'entities.OrderBy( ... ).ThenByDescending( ...)' by 'entities.MyExtensionSortMethod()' (no parameter as well). Here is a sample of implementation: //test function function Test(IEnumerable<ClassA> entitiesA,IEnum...

Is this implementation of Bucket-Sort considered "in-place"?

Consider the following implementation of bucket-sort: Algorithm BucketSort(S) input: Sequence S of items with integer keys in range [0,N-1] output: Sequence S sorted in nondecreasing order of keys. let B be an array of N sequences, each of which is initially empty for each item x in S do let k be the key of x ...

Sorting field list by caption in pivot table (OWC11)

Hi, is there a way I can sort pivot-table field list (measure names, attributes) by it's caption instead of default by name defined in the cube? Eventually, can I recreate the field list by hand? ...

Different way of sorting a list, depending on a variable in XSLT

I am making a newslist, and have until now sorted the news after their date. Newest first. But I would like to give the administrator of the site a more flexible solution. This means that in the backend, the admin can choose from a dropdown-list, in wich way he/she want's the list to be sorted. By date(newest first and oldest first), o...

GridView - Sorting Enum in Alphabetical Order

When sorting on a column in the GridView bound to an Enum, it sorts by the order of the Enum. I need it to sort by the string representation of the Enum. Here are the options I have seen, of which I like none of them. Reorder the Enum in alphabetical order - Bad because now the presentation is relying on the Business and Data Access ...

Sort a set of <li>'s alphanumerically.

I've been playing around trying to get a function that will sort a selection of li tags by their content but currently to no avail (at least no speed/accuracy); $('.sortasc').live('click',function(){ var liArr = Array(); $('#licontainer').children('li').each(function(){ liArr.push($(this).html()); })...

Sorting List<MyObject>

Which is the quickest way in Java to sort a list List<MyObject> myObjectList based on some numerical property of MyObject? ...

VisualBasic (or Applescript) Excel Sheet sorting with names

Hi All I have a big problem in the moment. I have to sort out an Excel sheet with names in it. There is always a first name and a last name following each other in the same order. Each name fills a cell. These Cells are alligned in one row. Example Bill|Cospy|James|Bond|George|Clony|Michael|Jacksson Now I want that each first name a...

Sorting Algorithm

I have this linked list containing hashed values of a set images. I am plan to run a simplistic but a very quick sort for the same and so far I am stuck with just two of them, merge sort and quick sort. My quick sort implementation seems to have gone haywire and is taking a painstakingly long 15 seconds (approx.) to sort out over 10 im...

Sort Points vertically then horizontally

I have an array of Points and i want to sort then both vertically and horizontally. Should I sort twice? ...

Interactive Sorting on Top Group's aggregate data in SQL Reporting 2005

I have a report that has a group row that shows a group name and sum details in certain columns. Then a details row within the group. I show the detail rows hidden to begin with and an expansion button. That part works. I also want to be able to sort on the group's aggregate data, not detail data. So when the detail rows are hidden, some...

How does Javascript's sort() work?

How does the following code sort this array to be in numerical order? var array=[25, 8, 7, 41] array.sort(function(a,b) { return a - b}) I know that if the result of the computation is... Less than 0: "a" is sorted to be a lower index than "b". Zero: "a" and "b" are considered equal, and no sorting is performed. Greater th...

jquery sorting dom elements based on its css("color")

Hello! What you can see on following page is a list of usernames in some random order. I want to use jquery to sort them in this order: red blue green purple black http://www.arvag.net/test/sorting/ This is what i did so far: <script type="text/javascript"> $(function() { var admin = "rgb(255, 0, 0)"; var moderator = "rgb...

sort nodes based on multiple attributes?

I want to sort nodes base on attributes. Say there are three attributes A, B and C in element E1. I know that a sub-group of nodes have the same value of attribute A and B. How can I get this sub-group retrieve the node that has the max value of C? The tricky part here is that I don't know what value of A is. I just know that sub-group s...

How do I sort by value from a second level hash, in Perl?

my $hash_ref = { one => { val => 1, name => 'one' }, three => { val => 3, name => 'three'}, two => { val => 2, name => 'two' }, }; I would like to sort $hash_ref such that a foreach would order them by $hash_ref->{$key}->{'val'} one two three Any suggestions? ...

Sorting <li> tags

I have a a and I would like to sort my list alphabetically (I don't want caps to matter) according to a class named "name". How would I do this? <ul class="column"> <li> <table> <tr> <td class="name" >Name of Item</td> </tr> <tr> <td>Content</td> </tr> <tr> <td>morecontent</td...

How to sort structure arrays in MATLAB?

I'm working with an image retrieval system using color histogram intersection in MATLAB. This method gives me the following data: a real number which represents the histogram intersection distance, and the image file name. Because they are different data types, I store them in structure array with two fields, and then I save this structu...

Is there a simple way to alphabetize a String Enumeration in Java?

Just as the title says. I tried messing around a bit with Collections.sort() on a List[] and the .sort() function of an ArrayList but I was never able to parse it back to an Enumeration. Thanks! EDIT: Here's some pseduocode and further explanation. My goal is to take the keys() from a Hashtable and do complex operations involving eac...

SQL how to make null values come last when sorting ascending

Hello! I have a SQL table with a datetime field. The field in question can be null. I have a query and I want the results sorted ascendingly by the datetime field, however I want rows where the datetime field is null at the end of the list, not at the beginning. Is there a simple way to accomplish that? ...

Want to sort by association records count in Datamapper

Lets say I have the following DataMapper resources: class Post include DataMapper::Resource has n, :comments ... end class Comment include DataMapper::Resource belongs_to :post ... end To get the ordered list of posts, I know you can do: @posts = Posts.all(:order => :date.desc) But lets say I want to display al...