sorting

gridview sort not working for numbers

I have implemented the sort function in my codebehind, it works fine with words but not with numbers... eg 4,693 1,494 23 when i sort this i get > 1,494 > 23 > 4,693 so this means its just checking the first number.... my code for sort is: protected void GridView1_Sorting(object sender, GridViewSortEventArgs e) { ...

Groovy: Sorting Columns in a view: list

Hi! I have a Groovy application. I am rendering the view list using the following statement: render (view: 'list', model:[reportingInstanceList: reportingInstanceList, reportingInstanceTotal: i, params: params]) The list.gsp is as follows: The view is rendered but the default sorting is not working. <g:sortableColumn class="tabtitle...

Slow performance selecting next message from custom queue

Hi all, I have a simple table based queue system. In its simplest form, it consist of an id, a queue name, and a status. When reading the next message from a given queue, we need to ensure FIFO (first in first out), i.e. the lowest id from the given queue with the given status. This all works fine with some thousand rows, but when we re...

Flattening a forest into a sorted list, using only the set of nodes and an "is parent" predicate (or: sorting a list with an incomplete comparison function)

I have a set of objects, and I need to produce a sorted list, but my comparison function is incomplete and leaves some room for "imagination" on the part of the sorting algorithm. Specifically, given a collection of trees like the following: A E | | B--C F | D What I have on hand is the set of nodes {A, B, C, D...

When is each sorting algorithm used?

What are the use cases when a particular sorting algorithm is preferred - merge sort vs quick sort vs heap sort vs introsort, etc? Is there a recommended guide in using them based on the size, type of data strucutre, available memory and cache, and CPU performance. thanks, Sam ...

why is in place merge sort not stable?

The implementation below is stable as it used <= instead of < at line marked XXX. This also makes it more efficient. Is there any reason to use < and not <= at this line? /** class for In place MergeSort **/ class MergeSortAlgorithm extends SortAlgorithm { void sort(int a[], int lo0, int hi0) throws Exception { int lo = lo0; ...

Custom sort-order with SQL-Server and .NET Entity-Framework

Hello! I have a table I store contacts and their phones. Contact: ContactId (int, PK), FirstName (varchar), LastName (varchar) Phone: PhoneId (int, PK), ContactId(int FK), Number (varchar), SortOrder (tinyint) I want that under each contact, the user should be able to maintain the priority of the phones, meaning that the SortOrder co...

Sorting a text file with over 100,000,000 records

Hi I have a 5gig text file that needs to be sorted in alphabetical order What is the best algorithm to use? constraints: Speed - As fast as possible Memory - A Pc with 1 Gig Ram running windows XP ...

Sorting an array with minimal number of comparisons

I need some help with my CS homework. I need to write a sorting routine that sorts an array of length 5 using 7 comparisons in the worst case (I've proven that 7 will be needed, because of the height of the decision tree). I considered using the decision tree 'hard-coded', but that means the algorithm is really complicated and was hinte...

ASP.Net: Sorting, GridView BoundColumn vs. TemplateColumn

With everything else being equal, a BoundField column in an asp:GridView is sortable, but a TemplateField column is not. Why is that? <asp:LinqDataSource ID="someDataSource" runat="server" ContextTypeName="someDataContext" TableName="someTable" OnSelecting="someSelectingHandler" /> ...

Custom sort xml bound DataGridView

I have a DataGridView bound to xml file. I would like to sort by first column and treat values as integers (not strings). XmlDataDocument xml = new XmlDataDocument(); xml.DataSet.ReadXml("file.xml"); dataGridView.DataSource = new BindingSource(xml.DataSet, "Item"); Sort(IComparer) doesn't work Sort(DataGridViewColumn,ListSortDirecti...

Trying to sort queryset...

Hi. I have model like this: class Kaart(models.Model): name = models.CharField(max_length=200, verbose_name="Kaardi peakiri", help_text="Sisesta kaardi pealkiri (maksimum tähemärkide arv on 38)", blank=False, null=False) url = models.CharField(max_length=200, blank=False, null=False, verbose_name="Asukoha URL", help_text="Täisa...

Python sorts "u11-Phrase 1000.wav" before "u11-Phrase 101.wav"; how can I overcome this?

Hello, I'm running Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] on win 32 When I'm asking Python >>> "u11-Phrase 099.wav" < "u11-Phrase 1000.wav" True That's fine. When I ask >>> "u11-Phrase 100.wav" < "u11-Phrase 1000.wav" True That's fine, too. But when I ask >>> "u11-Phrase 101.wav" < "u11-Phr...

How to properly sort MPTT hierarchy data into multidimensional array ?

Helo there, im trying to figure out how to write a function that returns a multidimensional array, based on the data below: I know how to write the function using the "category_parent" value, but im just trying to write a function that can create a multidimensional array by JUST using the left and right keys. Any help greatly appreciat...

why in place merge sort not stable?

Possible Duplicate: why is in place merge sort not stable? I wrote a simple implementation that is very similar to normal merge sort (using additional memory) but adds complexity. I don't understand why in place merge sort is not stable. The behavior is the same as merge sort. See the blow implementation: /** class for In plac...

How do I sort this array in JavaScript?

How do I sort this array? [ {id : 1, start : 60, end : 120}, {id : 2, start : 100, end : 240}, {id : 3, start : 700, end : 720} ] UPDATE: So if my array looks like this, can I sort it based on start value? [{ 1:{start : 60, end : 120}, 2:{start : 100, end : 240}, 3:{start : 700, end : 720} }] ...

sort an array and assign new numerical keys?

i have an array like this (after i unset some elements): $array[3] = 'apple'; $array[5] = 'pear'; $array[23] = 'banana'; which function do i use to sort them to: $array[0] = 'apple'; $array[1] = 'pear'; $array[2] = 'banana'; i tried some of the sort functions but it didnt work. ...

C# Given a desired order need a space efficient list reordering or sorting

My objective is: Given a list of entries, and a desired ordering, rearrange the list of entries according to this ordering. The list will be very large, so space efficiency is important. Ex: List<Entry> data = ReadDataFromSomeWhere(); // data => [a, b, c]; List<int> ordering = RandomPermutation(data.Count); // ordering => [2, 1, 3]; da...

Joining two SQL tables with GROUP BY not achieving desired results

For example, I have a shop order database, and two tables in it - ORDERS and ORDERSTATUS. Table : orders -------------------------------------------- OrderID | OrderItems | AddedTimeStamp | -------------------------------------------- 1 | Apples | 2009-12-22 13:15:18 | -------------------------------------------- 2 ...

Sort ArrayBuffer[A] in scala?

I have an array in scala with the class "ArrayBuffer[Actor]", where Actor is a class that implements the "Ordered[Actor]" trait. How do I sort this array without coding it manually? I know there is an Object called Sorting, but it doesnt seem to work since ArrayBuffer doesn't implement/extend the right classes. How do I sort ArrayBuffe...