sorting

How can I sort a hash of hashes by key in Perl?

I want to sort a hash which actually has a hash as a value. For instance: my %hash1=( field1=>"", field2=>"", count=>0, ); my %hash2; $hash2{"asd"}={%hash1}; and I inserted lots of hashes to %hash2 with different count values of %hash2. How can I sort the %hash1 according to a count value of hash1? Is there a way of doing ...

Sort a mysql table using php,ajax and jquery

Hello Everyone Ok here is the deal i am building a messaging system by php,ajax,jquery and mysql i add the new message and i add in 2 rows now what i want to do is to send an ajax request to server and recieve an updated version of the table but sorted So how can i do so //here i add and call the message the message function addMsg()...

Seeking class that allows a custom sort method

I wrote a small app that allows me to compare two database schemas to check for differences in structure. It goes all the way down to column details, which is nice. When I was comparing very small databases, I had no trouble but when I start to compare databases with hundreds of tables, it is annoying to scroll up and down to find where ...

How to sort a bunch of polygons/polyhedra by a specific value at their vertices (or some other distance measure)

I am working on a project which will be using large datasets (both 2D and 3D) which I will be turning into triangles, or tetrahedra, in order to render them. I will also be performing calculations on these tris/tets. Which tris/tets to use for each calculation depend on the greatest and smallest values of their vertices. So I need to ...

Finding best position for element in list

Hello, I have List collection that is populated in specific order (the requirement is that, this order can not be changed). This list contains entity type objects. After initial population of the list, I need to insert few more object, that are coming from another data source. These objects need to be inserted at specific position, so...

Sorting in linear time?

Given an input set of n integers in the range [0..n^3-1], provide a linear time sorting algorithm. This is a review for my test on thursday, and I have no idea how to approach this problem. ...

Sort using php and jquery

I'm trying to re-order a HTML table when the user clicks on the table header. Here is all I can do, but still doesn't work. in the HTML: // onClick on table header var par='ASC'; sort(par); from: ajax.js function sort(orderByType) { $.ajax({ url: "sort.php", type: "get", data: "orderby="+orderByType, success: func...

Sorted Combination of Multiple Lists

Consider L1, L2, L3 as lists containing n1, n2 and n3 integers in sorted order respectively. Task is to construct a sorted list L such that, L[0] = L1[0] + L2[0] + L3[0] L[i] = L1[i1] + L2[i2] + L3[i3] L[n1 * n2 * n3] = L1[n1] + L2[n2] + L3[n3] But n1, n2, n3 are very large and therefore L cannot be constructed in one go and then s...

What sort does Java Collections.sort(nodes) use?

I think it is MergeSort, which is O(n log n). However, the following output disagrees: -1,0000000099000391,0000000099000427 1,0000000099000427,0000000099000346 5,0000000099000391,0000000099000346 1,0000000099000427,0000000099000345 5,0000000099000391,0000000099000345 1,0000000099000346,0000000099000345 I am sorting a nodelist of 4 no...

Edit messing up after Gridview_Sorting

I have a web app (ASP.NET 2.0 C#), and on one of the pages I have a Gridview. The Gridview has 3 columns (Edit, ID, Name), and sorting is enabled. The Edit doesn't work in the conventional way: It uses the ID and adds it to the QueryString, and the user is taken to the Edit page. Something like this: protected void Grid_RowEditing(obj...

Sort by value hash of hash of hashes Perl

I have a hash structure similar to the following: KeyA => { Key1 => { Key4 => 4 Key5 => 9 Key6 => 10 } Key2 => { Key7 => 5 Key8 => 9 } } KeyB => { Key3 => { ...

HQL: How to sort list of objects on property of mapped composite element

Hi everyone, I have an object with a map of components: <class name="Article" table="articles"> ... <map name="i18nData" table="articles_i18n"> <key column="id" not-null="true"/> <map-key column="language" type="string"/> <composite-element class="Article$ArticleI18nData"> <property name="displayName" type...

DataTable column sort in ASCII order, not

If I have two strings, and I need to compare them in ASCII order (instead of the invariant culture order) I can generally use: int c = String.Compare(a, b, StringComparison.Ordinal); If I have a DataTable, and I want one of the columns sorted using an Ordinal string comparison for the DataView , how do I go about it? ...

D Templates: Sort a list of types

Assume you have a type like the following: struct Value(int v_) { static const v = v_: } How would you sort a list of these types, assuming an interface something like this: alias Sorted!(Value!(4), Value!(2), Value!(1), Value!(3)) SortedValues; You may use D 2.x features if it makes for a better solution, but please state if you...

Sorting a graph to make as many arrows point forward as possible

I need to sort the nodes of a directed graph such that the number of arrows that flow backwards (against the sorting order) is minimal. I can think of algorithms (e.g. keep swapping nodes until no swap will improve things) but I'm not sure how fast they run or whether they arrive at the best solution. What is the name and complexity of...

Optimize a list<T>.Sort(Comparer)

Hi, I have a list which stores a lost of integers. I don't like the default List.Sort() works, as I want the list to be ordered by size of the actual int. So far I have this: Oh, and the ints are stored in strings, e.g "1234". It is something I can not change. public class IntComparer : IComparer<string> { public int Compare(strin...

What sort algorithm provides the best worst-case performance?

What is the fastest known sort algorithm for absolute worst case? I don't care about best case and am assuming a gigantic data set if that even matters. ...

ASP.NET TreeView sort

I am accustomed to winform TreeView having a Sorted property which automatically manages nodes sorting. I now have to alphabetically sort an ASP.NET TreeView and I'm surprised I cannot find any similar property or callback method. Is there any way to automatically achieve this operation in ASP.NET or do I have to manually sort and inser...

Pagination in a REST web application

This is a more generic reformulation of this question (with the elimination of the Rails specific parts) I am not sure how to implement pagination on a resource in a RESTful web application. Assuming that I have a resource called products, which of the following do you think is the best approach, and why: 1. Using only query strings e...

Sorting an associative array in PHP

I have an array in this format: Array ( [0] => Array ( [text] => tests [language] => [advertiserCompetitionScale] => 5 [avgSearchVolume] => 7480000 [lastMonthSearchVolume] => 9140000 ) [1] => Array ( [text] => personality tests ...