sorting

How can I cluster a graph in Python?

Let G be a graph. So G is a set of nodes and set of links. I need to find a fast way to partition the graph. The graph I am now working has only 120*160 nodes, but I might soon be working on an equivalent problem, in another context (not medicine, but website development), with millions of nodes. So, what I did was to store all the lin...

How do you normally sort items in Rails?

I have a little example Rails app called tickets, which views and edits fictional tickets sold to various customers. In tickets_controller.rb, inside def index, I have this standard line, generated by scaffolding: @tickets = Ticket.find(:all) To sort the tickets by name, I have found two possible approaches. You can do it this way: @...

Adding new row in correct position to a user sorted wingrid with bindingsource

I have a Infragistics UltraGrid using a bindingSource. If I add a new object to my binding list, it adds a row to the bottom of the grid which is fine if there's no user defined sort. Question is if the user clicks on a column header to sort the grid, is there a way for new rows to appear in the proper sorted order instead of always on...

Is there C# support for an index-based sort?

Is there any built-in C# support for doing an index sort? More Details: I have several sets of data stored in individual generic Lists of double. These are lists always equal in length, and hold corresponding data items, but these lists come and go dynamically, so I can't just store corresponding data items in a class or struct cleanly....

How to sum an attribute in a sphinx group search?

I need sphinx to sort the results by the sum of an attribute. I need to: Group the results by their IDs (done) Sort the results by the SUM of one attribute I can't find a way to sum this attribute. How could I do this? (Im using sphinx PHP API) ...

Extract first N unique integers from an Array

I have a large list of integers (thousands), and I want to extract the first N (in the order of 10-20) unique elements from it. Each integer in the list occurs roughly three times. Writing an algorithm to do this is trivial, but I wonder what's the most speed and memory efficient way to do it. There are some additional constraints and ...

Sorting dropdown list using Javascript

Hi, i want to sort the drop down items using javascript,can anyone tell me how to do this. ...

Keeping top 5 values in PHP efficently

I'm writing a small algorithm in PHP that goes through n number of movies with ratings, and will store the top 5. I'm not reading from a datafile, but from a stream so I cannot simply order the movies by rating. My question is what is the most efficent way to keep track of the top 5 rated movies as I read the stream? Currently I do the ...

Sorting x and y coordinates in an array in PHP most efficently?

Currently I have an array that contains x and y coordinates of various positions. ex. $location[0]['x'] = 1; $location[0]['y'] = 1 This indicates id 0 has a position of (1,1). Sometimes I want to sort this array by x, and other times by y. Currently I am using array-multisort() to sort my data, but I feel this method is inefficient s...

Sorting in Web Applications

With the increasing popularity of powerful client side javascript widgets, I am curious on when is the best time to handle the sorting of data strictly on the client side, making use of widgets such as those found in YUI, and when to make a request to the backend and have it handle the sorting via a DB query or other means. ...

Is it possible to add an option to the Arrange Icons menu?

I have written a short console based C# application which automatically arranges my desktop icons. Is it possible to add an entry into the desktop "Arrange Icons By" menu for my custom sorting? ...

Is it possible to sort a HashTable?

I have a property that returns a HashTable. I would like to sort it without refactoring my property. Please note: I do not want to return another type. Code: /// <summary> /// All content containers. /// </summary> public Hashtable Containers { get { Hashtable tbl = new Hashtable(); ...

Pagination and sorting in a Rails RESTful application

Any tips on how to implement sorting and pagination on a resource in a Rails application and still keeping it RESTful? How do I map the parameters for page number and sort field in a clean way? (I am currently using map.resources :x for every resource in my app) Any other performace issues involved that I should know about? (eg. cachi...

VB6 - How to do a multi level sort with MSFlexGrid?

I currently have a VB6 program that essential reads data from an excel worksheet and spits it out into a MSFlexGrid. Below is the excel sheet data that is read in. Data is filled into the occurence column for the left half of the table. The VB6 Application then read this data into a multi dimensional array which is then fed into a M...

PHP: sort array by half-hour intervals

I have a very specific problem here. I have a multi-dimensional array that I want to sort first by half-hour time intervals, second by dates. The function array_multisort will not meet my requirements. Example: I want: array(array("time"=>"12:15", "date"=>"2009-03-24"), array("time"=>"12:10", "date"=>"20...

Quick Sort Vs Merge Sort

Why might quick sort be better than merge sort ? ...

Best way of sorting a list of strings based on difference from a target string?

I need to sort a List based on the difference between the strings in the list and a target string. What's the best way of implementing this kind of sorting algorithm? I don't care too much about performance but the collection could potentially become big (let's say half a million tops). Any Help Appreciated! ...

XSLT: Getting the latest date

I have a structure like this: <Info ID="1"> ... <Date>2009-04-21</Date> </Info> <Info ID="2"> ... <Date>2009-04-22</Date> </Info> <Info ID="3"> ... <Date>2009-04-20</Date> </Info> I want to get the latest date using XSLT (in this example - 2009-04-22). ...

Pagination and table sorting in Rails

I am using will_paginate and sort helper for pagination and sorting resp.. But im facing one problem while sorting that when im on page 2 or 3 or any other page than first page. It redirects to the first page and sorts the first page only. please help me how to sort all the records and go back to page where I was. ...

Flex 3 sorting object fields

i have an object in actionScript3 code which i need to sort, i iterate through the object and print out each value for (var i:String in columnData) { however i need the data im iterating to be sorted aplhabetically. any suggestions on how to do this? ...