sorting

Sorting by foreign key values in GridView with Entity Framework?

When using GridView's built in Sorting with Entity Framework, I can display foreign key values. For example... <asp:boundfield HeaderText="Category" DataField="Category.Name" SortExpression="Category.Name" /> ...but when the header is clicked to sort the items in the grid, how can I sort my List list by Category.Name? I only have th...

Why does Perl's Inline::C sort 4.0e-5 after 4.4e-5?

I built a Perl Inline::C module, but there is some oddity with the sorting. Does anyone know why it would sort like this? Why is the 4.0e-5 is not first? my $ref = [ 5.0e-5,4.2e-5,4.3e-5,4.4e-5,4.4e-5,4.2e-5,4.2e-5,4.0e-5]; use Inline C => <<'END_OF_C_CODE'; void test(SV* sv, ...) { I32 i; I32 arrayLen; AV* data; float ret...

How to sort an NSMutableArray with custom objects in it?

What I want to do seems pretty simple, but I can't find any answers on the web. I have an NSMutableArray of objects, let's say they are 'Person' objects. I want to sort the NSMutable array by Person.birthDate which is an NSDate. I think it has something to do with this method: NSArray *sortedArray = [drinkDetails sortedArrayUsingSelect...

Sorting tuples in F#

I have a list of tuples representing coordinates of points. How can I sort them by the first or second value, so that I could order my points from left to right first and from top to bottom next? ...

Sort dataGridView colums in C# ? (Windows Form)

Hello there, I have a datagridview that i bind from an sql table, in that dv i have those attributes: Id, Name and Price. When i set the SortMode of the Name Columns to Automatic and i click on the header of this column i can sort this dv based on the first letter of the Name, this way i can order products based on their first letters ( ...

assigning comparer to ListViewItemSorter

Hi, I want to sort a ListView control in C# based on columns. I have created ColumnClickEventHandler: private void contactsListView_ColumnClick(object sender, ColumnClickEventArgs e) { contactsListView.ListViewItemSorter = new ListViewItemComparer(e.Column); contactsListView.Sort(); } Where ListViewItemCom...

sorting a ruby array of objects by an attribute that could be nil

Hi All, I have an array of objects that I need to sort by a position attribute that could be an integer or nil, and I need the objects that have the nil position to be at the end of the array. Now, I can force the position to return some value rather than nil so that the array.sort doesn't fail, but if I use 0 as this default, then it p...

What is the benefit for a sort algorithm to be stable?

A sort is said to be stable if it maintains the relative order of elements with equal keys. I guess my question is really, what is the benefit of maintaining this relative order? Can someone give an example? Thanks. ...

C# Windows Form TreeView Sort after LabelEdit

After a node's label is edited in the tree I try to resort the nodes to place the updated item in the right position. I do this by calling .Sort in AfterLabelEdit event handler which causes an infinite loop. How can I resort the nodes in a treeview after a label has been changed? ...

Sort Array of MultiDiminsional Arrays on More Than One "Column" (Key) With Specified Sort Options

I'm looking to be able to sort an array of multi-dimensional arrays on more than one column. To further complicate it I'd like to be able to set specific sort options per key/column. I have what is similar the result of a DB query, but doesn't actually come from one, therefore the need to sort it in PHP rather than SQL. Array ( [0] ...

Using Perl, how can I sort an array using the value of a number inside each array element?

Let's say I have an array, @theArr, which holds 1,000 or so elements such as the following: 01 '12 16 sj.1012804p1012831.93.gz' 02 '12 16 sj.1012832p1012859.94.gz' 03 '12 16 sj.1012860p1012887.95.gz' 04 '12 16 sj.1012888p1012915.96.gz' 05 '12 16 sj.1012916p1012943.97.gz' 06 '12 16 sj.875352p875407.01.gz' 07 '12 16 sj.875408p87543...

hibernate sorting

hey i want to do nested sorting in hibernate. i has a set of application in course object .application has a time and type attribute I want to sort by type first and then within application of particular type i want to sort it by time. can i use it as follows?? order-by="type desc,time asc " note that type should be sorted descending...

SQL paging sorting

I need to display a grid on a webpage. The data will come from SQL Server 2008 through a stored procedure. As the sproc returns thousands of records, I decided to go for a paging option which works fine. In the stored procedure, I do something like this: declare @RowIdMin int=10 declare @RowIdMax int=25 select * from ( select C...

How big is the performance gap between std::sort and std::stable_sort in practice?

Both should run in O(n log n), but in general sort is faster than stable_sort. How big is the performance gap in practice? Do you have some experience about that? I want to sort a very large number of structs that have a size of about 20 bytes. The stability of the result would be nice in my case, but it is not a must. At the moment the...

Sort Japanese Text using "aiueo" order

Hi I am trying to sort some Japanese shop names using the "aiueo" order Does anyone know if there is an algorithm to do this I have written a comparer as follows but I believe the ja-jp culture uses the Unicode sort internal class JewellerComparer : IComparer<string> { private readonly string _culture; public Jew...

C#: custom array sorting

Hi, I would like to sort an array of strings in a directory, given a custom mapping (it's actually a sorting of stock names based on their sector). I am unsure of what data structures to use to represent the mapping, and how to write the custom sort method. So for instance, suppose I had the following string array: string[] fileNam...

How do I Sort Collections in Objective-C?

I have an integer array in my Objective-C program. I'd like to sort it (ascending or descending, doesn't matter). In C++ I'd use the sort algorithm in the STL Algorithm library. How can I do this? ...

How to sort search results on multiple fields using a weighting function?

I have a Lucene index where every document has several fields which contain numeric values. Now I would like to sort the search result on a weighted sum of this field. For example: field1=100 field2=002 field3=014 And the weighting function looks like: f(d) = field1 * 0.5 + field2 * 1.4 + field3 * 1.8 The results should be ordered ...

Sort using jquery and php

Hello Gurus what is wrong with this code it works the first time then when i build the header again an error occurs saying From is undefined Jquery function sort(tableHeader,sortDir) { $.ajax({ url: "sort.php", type:"get", data: "tableHeader="+tableHeader +"&sortdirection="+sortDir, success:function(data){ $("#t1").html(data);}...

Sorting a list with paths by deepest directory

Hello. I need to sort a list that contains paths (relative or absolute) so that the deepest path appears first, for example: \New Folder\Item1\tools\1 \New Folder\Item1\tools \New Folder\Item1 \New Folder etc... Is there an API in Path class I can use to do it? Thanks! J. ...