sorting

Sorting terms of custom taxonomy

How to set up special sorting for the terms of custom taxonomy? Thank you! ...

Counting sort - implementation differences

I heard about Counting Sort and wrote my version of it based on what I understood. public void my_counting_sort(int[] arr) { int range = 100; int[] count = new int[range]; for (int i = 0; i < arr.Length; i++) count[arr[i]]++; int index = 0; for (int i = 0; i < count.Length; i++) { ...

Why can Linq operations be faster than a normal loop?

A friend and I were a bit perplexed during a programming discussion today. As an example we created a fictive problem of having a List<int> of n random integers (typically 1.000.000), and wanted to create a function that returned the set of all integers that there were more than one of. Pretty straightforward stuff. We created one linq s...

MySQL sort by 2 parameters

I have a MySQL table with 2 fields: pd_code and pd_sort (pd_sort default value=0). For each product it is possible to specify an order index (in pd_sort) -1000, -900 and so on. So when I print out products in PHP, i would like to sort them out like this. product1 (pd_sort = -100), product2 (pd_sort = -90) etc, and then the rest produc...

What's faster: inserting into a priority queue, or sorting retrospectively?

What's faster: inserting into a priority queue, or sorting retrospectively? I am generating some items that I need to be sorted at the end. I was wondering, what is faster in terms of complexity: inserting them directly in a priority_queue or a similar data structure, or using a sort algorithm at end? ...

Sorted List Array Question

Is it possible that two sorted list of size n/2 each can be merged using n/2 size of working ?array??? ...

JQGrid Sorting - how to trigger onSortCol event

I am trying to get the onSortCol event get fired when I press a column header. Currently, when I click a column header i can see a request going to the server but I want the onSortCol to be fired before this happens. I have pasted below the code I am using. Am I missing anything? How do i get onSortCol to work? jQuery("#list").jqGrid('...

how to sort a set using a Functor

hey, i am trying to sort my set container using afunctor: struct CompareCatId : public std::binary_function<Vehicale*, Vehicale*, bool> { bool operator()(Vehicle* x, Vehicle* y) const { if(x->GetVehicleType() > y->GetVehicleType()) return true; else if (x->GetVehicleType() == y->GetVehicleType() ...

What does sorting mean in double-byte languages?

I have some code that sorts table columns by object properties. It occurred to me that in Japanese or Chinese (non-alphabetical languages), the strings that are sent to the sort function would be compared the way an alphabetical language would. Take for example a list of Japanese surnames: 寿拘 松坂 松井 山田 藤本 In English, these would be S...

Sorting xml with either repater/xml functions in vb.net

Hi! I need to sort and choose only the last 5 inputs to my xml, Ill give you an idea of how my xml looks like. <News> <Article> <Headline>First</Headline> <Content>First</Content> <ID>1</ID> </Article> <Article> <Headline>Second</Headline> <Content>Second</Content> <ID>2</ID> </Article> </News> And im ...

How do I implement automatic sorting of DataGridView?

I am programmatically adding columns to a DataGridView and then binding to a list. By default, the SortMode of the columns are Automatic. But when I run my app, clicking on the headers does nothing. The up/down arrows aren't showing up. From reading MSDN, not much is said about automatic sorting. They go into more detail about progr...

Java Bucket Sort of Objects

I am asked to write my own version of Bucket Sort for Sorting an array of objects. My plan is to write a simple Entry class and another class with a main method and try to manipulate an array of lists. This is what I have so far, I just need some help putting it all together because I'm not very experienced with coding but I know what I ...

WPF datagrid : how to sort a column programatically ?

Hi, How do I sort a column programatically ? I would like to have a function such as myWPFDataGrid.Columns[0].Sort(..) MadSeb ...

How do I speed up JTable built in table sorting?

I have a JTable with a custom TableModel that extends AbstractTableModel. I have also used the built in table sorting by calling: table.setAutoCreateRowSorter(true); The model also return the right class of the data for each column from the getColumnClass() call, which from what I read should ensure the fastest sorting being done. W...

Prevent click events on Sortable of jQueryUI

Hi there, I have sortable, draggable and click events binded to the same DOM element. On sorting, I want the click event to be disabled. I am using the following code for draggable, which works fine: $('.selector').draggable({ start: function(event, ui) { ui.helper.bind('click.prevent', function(event) { event.preven...

C# sort Listbox, add to a sorted list

Hi, I want to sort the elements in C# listbox by some field in the object element. Is there a method in C# that perform this task? Maybe a function that receives a comparison function as a parameter or something like that? another thing, when the listbox is sorted I want to add an element to a sorted list. is there such a method? than...

Sort distributed couples from two lists

Having two lists, I want to get all the possible couples. (a couple can be only one element from list 1 and another from list 2) If I do a double "foreach" statement, I get it immediately (I am using python): couples = [] for e1 in list_1: for e2 in list_2: couples.append([l1, l2]) How can I sort couples list in a way tha...

Python Sort Two Dimensional Dictionary By First Key

I have a 2D dictionary in python indexed by two IPs. I want to group the dictionary by the first key. For example, the before would look like this: myDict["182.12.17.50"]["175.12.13.14"] = 14 myDict["182.15.12.30"]["175.12.13.15"] = 10 myDict["182.12.17.50"]["185.23.15.69"] = 30 myDict["182.15.12.30"]["145.33.34.56"] = 230 so for ke...

LINQ To SQL Dynamically Sorting

I want to pass the sort field and direction dynamically to the LINQ to SQL codes. But I could not find the way to perform like that because if I could not write users.OrderBy(d => Field); Is there any way to pass the dynamic field to sort? Thanks. private static IQueryable<user> GetUserData(String Field, String Direction) { User...

Java: How do I sort an ArrayList according to a natural ordering?

I have an ArrayList of instances of a class I created, each of which contains a single field with a String. I have implemented Comparable in the class I created. How do I sort the Array List? ...