sorting

Java recursion and Merge Sort

Hi y'all, I'm trying to write a simple merge sort program in Java, I'm seeing a lot of red in Eclipse. I'm still a beginner, and don't quite see whats wrong. thanks. -Kyle public class merge{ public static int[] mergeSub(int[] array, int left, int right){ if(left<right) { int mid = (left+right)/2; int[] a = ...

Sorting a ListView by multiple columns in C#

With ListView controls, you can specify a column to sort by, and there's a method to sort() whenever you want. However, this only allows for single column sorting. I'm keen to sort by say, Column A first, and then by Column F for when they are the same. I've found a few custom compare classes written online, but wondered if stackoverf...

Entity Framework and Sorting

I'm trying to sort a list of entities using a GridView in ASP.NET, but I can't seem to get it working following examples. I have a property called Name on my entity, and I'm trying to sort by a specified column if given, or the Name column if the sortExpression is empty. public static List<Product> GetProducts(int startRowIndex, int max...

like a List<string> but keeps the strings ordered?

I want something like a List<string>, but whenever I do an "Add", it keeps the list sorted. Any ideas? ...

Cakephp Pagination Sort data out of model

I currently have a query that results in the following recordset: Array ( [Contestant] => Array ( [id] => 1 [name] => test [age] => [city] => atest [telephone] => [email] => [email protected] [why_model_house] => a [highschool] => [photo] => 5329_119145013633_512383633_2487923_7196193_n0.jpg [active] => 1 ) [0] => Array ( [Contestant_votes...

Retrieving one element and filter by another

Having tried and failed to modify the XSL from here: http://stackoverflow.com/questions/399204/xslt-distinct-elements-and-grouping I'm posting here to ask if anyone could please help. I've basically got the same data structure (mine is actually an RSS feed of products) as in the above post, but I want to list the Description elements un...

NSArray of Dates sort

Consider this array. It has no keys, so I am not sure I can use NSSortDescriptor. What would be the best method to sort them? ( "Thursday, July 30, 2009", "Monday, September 07, 2009", "Wednesday, September 09, 2009", "Friday, August 14, 2009", "Saturday, September 05, 2009", "Monday, August 10, 2009", "Thu...

how to sort a collection by datetime in c#

I have a List that I need to sort by datatime, the class MyStuff looks like: public class MyStuff { public int Type {get;set;} public int Key {get;set;} public DateTime Created {get;set;} } I need to be able to sort the collection List by the Created (datetime) field. ...

How can I sort a linked list in C ?

Hi, Need to be able to either sort or insert entries to a linkedlist in alphabetical order. Is there a good way to do that? ...

Is my gridview paging/sorting inefficient?

Hi, I'm using a web service which returns a list of products. I created a Grid View programmatically and used the list as the datasource. However, I can't use the Paging/Sorting methods as it causes errors since I'm not using an ObjectSource control. I handled the paging and sorting manually, but I don't know if I'm doing it efficien...

Need help with complex sorting in SQL

Hi, I have a complex sorting problem with my SQL statement. I have a table with the following columns. No Time Value -- ---- ----- 1 0900 '' 2 1030 '' 3 1020 '' 4 1010 '' 5 1100 '' 1 1015 'P' 2 1045 'P' I want to sort this table by doing the following steps. Select rows from the ...

LIMIT 3 not returning the first three rows in sorted RS (I think)

In my table I have looked manually and found that the top three idle units have been idle for 17, 13 and 13 days. When I use this SQL statement to try and pull the three rows with the highest idle column value, I don't get these numbers, I get 8, 7 and 7. Is there some other command I should use to grab the first 3 rows of a sorted res...

How could I improve this C# randomising method?

I think I've settled on this as the most simple and unit-testable method for randomising a list, but would be interested to hear of any improvements. public static IList<T> RandomiseList<T>(IList<T> list, int seed) { Random random = new Random(seed); List<T> takeFrom = new List<T>(list); List<T> ret = new List<T>(takeFrom.Co...

Pre-sorting a DataGrid in WPF

I have a DataGrid in WPF app with several columns, including a Name column. If the users switches to a particular view, I want the data to be pre-sorted by Name (and I'd like a sort arrow to appear in the Name header just as if the user had clicked that header). However, I can't find the expected properties to make this happen. I was loo...

Iterate Doctrine Collection ordered by some field

I need something like this: $products = Products::getTable()->find(274); foreach ($products->Categories->orderBy('title') as $category) { echo "{$category->title}<br />"; } I know is it not possible, but... How can I do something like this without creating a Doctrine_Query? Thanks. ...

Ge the most recent date from a list - Ruby

I have an array of Ruby Date objects. How can I find the most recent datetime and the oldest datetime? thanks ...

How do I sort an array of hash references by one of the hash values?

First, please pardon my rusty Perl. I'm trying to modify Bugzilla's "whine.pl" to generate lists of bugs sorted by severity. So it gives me an array of hash references. Each hash contains a bunch of information about a particular bug (id, assignee, severity, etc). I want to sort the array by severity. What's the best way to do this? I'...

Data Structure for storing a sorting field to efficiently allow modifications

I'm using Django and PostgreSQL, but I'm not absolutely tied to the Django ORM if there's a better way to do this with raw SQL or database specific operations. I've got a model that needs sequential ordering. Lookup operations will generally retrieve the entire list in order. The most common operation on this data is to move a row to th...

Efficient Out-Of-Core Sorting

I'm trying to work out how to efficiently sort a huge dataset that won't fit in memory. The obvious answer at a high level is to sort a whole bunch of chunks that do fit in memory using some standard algorithm, write these out to disk, and then merge them. Merging them is the problem. Let's say the data divides up into C chunks, so I ...

WPF Datagrid sort on column with null elements.

Hi, I have a WPF Datagrid that I am using with a number of columns. One of the columns has some elements that are sometimes null and this causes an exception when I try and sort on this column. The definitions of the columns is something like: <dg:DataGrid.Columns> <dg:DataGridTextColumn Binding="{Binding MyObject.Field1}" Header="F...