sorting

Can't sort table with associative indexes

Hi, why I can't use table.sort to sort tables with associative indexes? ...

Array List Sorting

Hi, How would you sort an array list alphabetically or numerically? I am not really sure how a method sorting an array either alphabetically or numerically would work. Thanks! ...

A few sorting questions

I have found a way that improves (as far as I have tested) upon the quicksort algorithm beyond what has already been done. I am working on testing it and then I want to get the word out about it. However, I would appreciate some help with some things. So here are my questions. All of my code is in C++ by the way. One of the sorts I ha...

sort csv by column

Hi! I want to sort a CSV table by date. Started out being a simple task: import sys import csv reader = csv.reader(open("files.csv"), delimiter=";") for id, path, title, date, author, platform, type, port in reader: print date I used Python's CSV module to read in a file with that structure: id;file;description;date;author;pla...

ASP.NET Gridview - setting column header's css class from code behind?

Hey guys, what I am trying to do is add a method to my gridview's sorting event to add a class to the column being sorted so the user can know if the data is being sorted ascending or descending and on what column. I am currently trying to do it through a switch statement on the sort expression to determine what column it's coming from b...

Treating nils in sort function

Hello, I don't know how to handle nils my sort function gets. When I have this checking in it, table.sort crashes after some calls. if a == nil then return false elseif b == nil then return true end With this error:invalid order function for sorting. But according to the documenatiton, sort function should return false, if a ...

Has anyone seen this improvement to quicksort before?

Handling repeated elements in previous quicksorts I have found a way to handle repeated elements more efficiently in quicksort and would like to know if anyone has seen this done before. This method greatly reduces the overhead involved in checking for repeated elements which improves performance both with and without repeated elements....

How do I find the first 5 files in a directory with PHP?

How would I list the first 5 files or directories in directory sorted alphabetically with PHP? ...

Sorting an array of SimpleXML objects

I've read what I've found on Stackoverflow and am still unclear on this. I have an array of SimpleXML objects something like this: array(2) { [0]=> object(SimpleXMLElement)#2 (2) { ["name"]=> string(15) "Andrew" ["age"]=> string(2) "21" } [1]=> object(SimpleXMLElement)#3 (2) { ["name"]=> string(12) "Be...

C#: Sorting with anonymous function

Let's say I have a list of objects, and I want to sort it by the items DateModified property. Why can't I use a delegate like this? How should I sort these by DateModified if not as shown below: public string SortByDateModified(List<CartItem> items) { items.Sort(new Func<CartItem, CartItem, bool>((itemA, itemB) => { retu...

Sort multidimensional array of objects

I've had trouble with the examples in the PHP manual, so I'd like to ask this here... I have an array of objects.. Is there a way to sort it based on the contents of the object? For example, my array is: Array ( [0] => stdClass Object ( [id] => 123 [alias] => mike ) [1] => stdClass Obje...

How to specify an Order or Sort using the C# driver for MongoDB?

I'm trying to figure out how to sort a collection of documents server side by telling the C# driver what the sort order is, but it appears not to support that construct yet. Is it possible to do this any other way? ...

MySQL querying products from one table only if they appear in certain category table

I've got the following tables: Products: id, name, ... Products_in_Categories id, category_id, product_id Categories id, name, ... I have an admin page where I want to let him search products by name, catalog id etc. And of course by category and name and catalog id ... So without the category - it's really easy. But when I w...

Counting sort in java for tuples

Hi, I am building a class that has a mapping of strings to integers. So if I have 3 apples I would have a mapping of apples to 3. I need to write a class that sorts the name of the objects by decreasing numbers. So if I have (apples, 3) (oranges, 2) (bananas, 5) I will get (bananas, 5), (apples, 3), (oranges 2) I was wondering if t...

NSArray sort and isolate

I have an NSArray of names, I want to sort them alphabetically into a UITableView and separate them into sections. I have a tagged section at the top, being section 0. I want the names sorted aplhabetically to come after that. So all names beginning with A get put into section 1, B into section 2, and so on. I need to be able to someho...

help with grouping and sorting for TreeView in xaml

I am having problems getting my head around grouping and sorting in xaml and hope someone can get me straightened out! I have creaed an xml file from a tree of files and folders (just like windows explorer) that can be serveral levels deep. I have bound a TreeView control to an xml datasource and it works great! It sorts everything alp...

Sorting a hashtable based on its entry value (not the key)

I want to get the following code to work in the Java ME / J2ME environment. Please help: Hashtable <Activity, Float>scores = new Hashtable<Activity, Float>(); scores.put(act1, 0.3); scores.put(act2, 0.5); scores.put(act3, 0.4); scores.put(act5, 0.3); Vector v = new Vector(scores.entrySet()); Collections.sort(v)...

dojo datagrid custom sorting server side

Hello I am using dojo.data.ItemFileWriteStore to draw a dojo datagrid (which works fine) and the grid shows properly. I was using client side sorting and that was also working fine. but now I need to change the sorting and do that server side. For this I am trying to use onHeaderCellClick event, using which I am able to run a javascript ...

How can I apply a custom sort rule to a WPF DataGrid?

When the user does a column sort in my DataGrid, I want all null or empty cells to be sorted to the bottom, rather than the top. I wrote an IComparer<T> that makes sure blanks are always sorted downward, but I can't figure out how to apply it to the columns of my DataGrid. Note that the initial sort of the DataGrid, which I'm doing with...

JQGrid sorting on client side

I have tree-grid with autoloading nows. The goal is to sort the grid by tree column, right on client side. But each time I click on sort column header, it issues ajax call for sorting – but all I need is on-place sorting using the local data. Do I have incorrect grid parameters or tree doesn't work with client-side sorting on tree colu...