sorting

How to reverse items in WPF Datagrid?

If i have DataGrid which looks like: Col 1 Col 2 ------- ------- 1 a 2 b 3 c ... ... n n Can the order be reversed easily without sorting? So that n is first, and 1 is last. I have custom sort implemented from this article, but sorting the same column twice in a row calls sorting function twice (which is ...

Drupal: Sorting a view programmatically

Hey there. I'm trying to take the results of a view - using the function views_get_view_result() - and sort the array in a way I couldn't do from within the Views interface. So far so good. I've got a $rows variable with all of the stuff I need. Now... How do I put it back? :) Before I needed this sort, I used views_embed_view(), but I ...

How do I sort an array of custom classes?

I have a class with 2 strings and 1 double (amount). class Donator string name string comment double amount Now I have a Array of Donators filled. How I can sort by Amount? ...

Improved technique to store a filename in a variable?

Greetings, I need to store the filename of a log into a variable so my script can perform some checks on the daily log files. These logs always have a different name because they have a timestamp in the name. Currently I'm using a hodge podged method that pipes an ls command to sed, sort, cut, and tail in order to get the name out. C...

LINQ Sorting - First three need to be different manufacturers

My OM has a 'product' object. Each product has a 'manufacturer id' (property, integer). When I have a list of products to display, the first three are displayed as the 'featured products'. The list is already sorted in a specific sort order, putting the 'featured' products first in the list. However, I now need to ensure the featured...

dojo datagrid will make the page "jump" when sorting is changed

Hi, I have a Dojo Datagrid in one of my pages (which contains more content) and the following problem occurs: As soon as I click on a column header to change the sorting, the page will jump up as if I clicked on some HTML-anchor. Funny enough, the page jump will make the grid show only the first two rows after it jumped, instead of (e....

PHP Sort Array By SubArray Value

I've got the following structue of array: Array ( [0] => Array ( [configuration_id] => 10 [id] => 1 [optionNumber] => 3 [optionActive] => 1 [lastUpdated] => 2010-03-17 15:44:12 ) ...

Method to sort MYSQL results by an arbitriary letter (ie, show all rows starting with F first)

I have a column of states, and, depending on the query, I want to order by results by a particular state, then by id (Asc or Desc, depending). For instance, I might want to show all rows with state "HI", sorted by ID desc, and then all the other rows, sorted by id desc. I was hoping I could do this in one query, rather than getting all...

How will you sort strings in the following example ?

so i have a list of string {test,testertest,testing,tester,testingtest} I want to sort it in descending order .. how do u sort strings in general ? Is it based on the length or is it character by character ?? how would it be in the example above ?? I want to sort them in a descending way. ...

C# - How to implement multiple comparers for an IComparable<T> class?

I have a class that implements IComparable. public class MyClass : IComparable<MyClass> { public int CompareTo(MyClass c) { return this.whatever.CompareTo(c.whatever); } etc.. } I then can call the sort method of a generic list of my class List<MyClass> c = new List<MyClass>(); //Add stuff, etc. c.Sort(); ...

undo or reverse argsort(), python

Given an array 'a' I would like to sort the array by columns "sort(a, axis=0)" do some stuff to the array and then undo the sort. By that I don't mean re sort but basically reversing how each element was moved. I assume argsort() is what I need but it is not clear to me how to sort an array with the results of argsort() or more important...

ideas for algorithm? sorting a list randomly with emphasis on variety

I have a table of items with [ID, ATTR1, ATTR2, ATTR3]. I'd like to select about half of the items, but try to get a random result set that is NOT clustered. In other words, there's a fairly even spread of ATTR1 values, ATTR2 values, and ATTR3 values. This does NOT necessarily represent the data as a whole, in other words, the total ...

Delphi : Sorted List

I need to sort close to a 1,00,000 floating point entries in Delphi. I am new to Delphi and would like to know if there are any ready made solutions available. I tried a few language provided constructs and they take an inordinate amount of time to run to completion.(a 5-10 sec execution time is fine for the application) ...

C++ sort array of char pointers

Can you tell me what's wrong with my method? I ends up putting the same thing everywhre and it's actually not sorting. void sortArrays(){ int i, j; for(i=0; i<counter; i++){ for( j=0; j<i; j++){ if( strcmp(title_arr[i], title_arr[j]) < 0){ char* title_temp = title_arr[i]; ...

Gravity Sort : Is this possible programatically?

Hi, I've been thinking recently on using the Object Oriented design in the sorting algorithm. However I was not able to find a proper way to even come closer in making this sorting algorithm that does the sorting in O(n) time. Ok, here is what I've been thinking for a week. I have a set of input data. I will assign a mass to each of t...

How can I sort dates in Perl?

How can I sort the dates in Perl? my @dates = ( "02/11/2009" , "20/12/2001" , "21/11/2010" ); I have above dates in my array . How can I sort those dates? My date format is dd/mm/YYYY. ...

Sort an array with special characters - iPhone

Hi everyone, I have an array with french strings let say: "égrener" and "exact" I would like to sort it such as égrener is the first. When I do: NSSortDescriptor *descriptor = [[NSSortDescriptor alloc] initWithKey:@"name" ascending:YES]; NSArray *sortDescriptors = [NSArray arrayWithObject:descriptor]; NSArray *sortedArray = [myArray sor...

Sorting a string array in C++ no matter of 'A' or 'a' and with å, ä ö?

How do you sort an array of strings in C++ that will make this happen in this order: mr Anka Mr broWn mr Ceaser mR donK mr ålish Mr Ätt mr önD //following not the way to get that order regardeless upper or lowercase and å, ä, ö //in forloop... string handle; point1 = array1[j].find_first_of(' '); string forename1(array1[j].subst...

Sort a list of tuples without case sensitivity

How can I efficiently and easily sort a list of tuples without being sensitive to case? For example this: [('a', 'c'), ('A', 'b'), ('a', 'a'), ('a', 5)] Should look like this once sorted: [('a', 5), ('a', 'a'), ('A', 'b'), ('a', 'c')] The regular lexicographic sort will put 'A' before 'a' and yield this: [('A', 'b'), ('a', 5), ('...

heap sort function explanation needed

Hello, Can someone clearly explain me how these functions of heap sort are working?? void heapSort(int numbers[], int array_size) { int i, temp; for (i = (array_size / 2)-1; i >= 0; i--) siftDown(numbers, i, array_size); for (i = array_size-1; i >= 1; i--) { temp = numbers[0]; numbers[0] = numbers[i]; numbers[...