sorting

which java collections (and maps) can be sorted by last access

Hi, i know that the LinkedHashMap provides a constructor, where you can indicate if the map should be sorted by the access order thus effectively providing an LRU implementation. Can you tell me which (and if) other Collections and Maps from the big Collections zoo provide this feature? ...

can we compare time fields in SORT card of JCL

Suppose I have 12 position of a record holding time field of 8 bytes. Can I compare it with current timestamp? Can I do arithmetic operations on that filed like adding an hour or subtracting few minutes etc. Your responses will be highly appreciated. Thanks! Addendum.. for better understanding: I need your help in getting time fields c...

jquery quicksand custom sorting methods? & 2 attributes?

Hi people, how to code the sorting method, i have a datetime formatted as 2010-09-26, how would i code it for quicksand? and how would i possible add another attribute(data-id), im listing out a bunch of images, and using quick sand to sort them into image types, and also need a additional attribute for sorting the 'latest' attribute. ...

Custom sort in Drupal Views

I have a View that uses fields from the Biblio module and those are unfortunately all defined as text fields. I need to sort my view according to the accession number, but if define the sorting in the View it sorts the numbers wrong like 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20 ... instead of 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11...

Sorting a ListView in C# causing crashes

I'm attempting to sort a ListView using C#, but whenever I click the sort button it crashes the webpage. Here's my ASP.NET code: <asp:ListView ID="list" runat="server" OnSorting="list_Sorting"> <LayoutTemplate> <asp:LinkButton runat="server" ID="Sorter" CommandName="Sort" CommandArgument="DispName" Text="Display...

Is this a correct way of sorting by title, position and then order by using a Comparator?

Consider this class. public class DynamicField implements Comparable<DynamicField> { String title; int position; int order; @Override public int compareTo(DynamicField o) { if(position < o.position) return -1; if(position > o.position) return 1; if(order < o.order) ...

Javascript natural sort array/object and maintain index association

I have an array of items as follows in Javascript: var users = Array(); users[562] = 'testuser3'; users[16] = 'testuser6'; users[834] = 'testuser1'; users[823] = 'testuser4'; users[23] = 'testuser2'; users[917] = 'testuser5'; I need to sort that array to get the following output: users[834] = 'testuser1'; users[23] = 'testuser2'; us...

Perl sorting; dealing with $a, $b package globals across namespaces cleanly

Suppose I have a utility library (other) containing a subroutine (sort_it) which I want to use to return arbitrarily sorted data. It's probably more complicated than this, but this illustrates the key concepts: #!/usr/local/bin/perl use strict; package other; sub sort_it { my($data, $sort_function) = @_; return([sort $sort_fun...

Understanding Assembly

I've got some assembly of a sorting algorithm and I want to figure out how exactly it functions. I'm a little confused on some of the instructions, particularly the cmp and jle instructions, so I'm looking for help. This assembly sorts an array of three elements. 0.00 : 4009f8: 48 8b 07 mov (%rdi),%rax ...

Algorithm problem: Packing rods into a row

Alright, this might be a tricky problem. It is actually an analogy for another similar problem relating to my actual application, but I've simplified it into this hypothetical problem for clarity. Here goes: I have a line of rods I need to be sorted. Because it is a line, only 1 dimension needs to be of concern. Rods are different l...

How can I store raw data with respect to time and sort it?

Hi to all, due to Internet communication i could have two (or more) ASCII files in RINEX format (GPS ASCII format) of the same data period, which i would like to merge to one file. Each data set (epoch) contain more then one line (in this example 19 lines). I would like to merge those files, where it could be that they in some parts ov...

sql select without sort

I guess this is a long shot but, is there a way to list the sql query without sorting... eg. I have select * from items where manufacID = 2 or manufacID = 1 or manufacID = 4 and I don't want them to be listed in the asc or decs order, but as i typed in... so 2,1,4. So, can i do that? ...

Advanced sorting criteria for a list of nested tuples

I have a list of nested tuples of the form: [(a, (b, c)), ...] Now I would like to pick the element which maximizes a while minimizing b and c at the same time. For example in [(7, (5, 1)), (7, (4, 1)), (6, (3, 1))] the winner should be (7, (4, 1)) Any help is appreciated. ...

Sorting items into bins in MATLAB

If I have a set of data Y and a set of bins centered at X, I can use the HIST command to find how many of each Y are in each bin. N = hist(Y,X) What I would like to know is if there is a built in function that can tell me which bin each Y goes into, so [N,I] = histMod(Y,X) would mean that Y(I == 1) would return all the Y in bin 1...

Bash: sort text file by last field value

Hi All, I have a text file containing ~300k rows. Each row has a varying number of comma-delimited fields, the last of which is guaranteed numerical. I want to sort the file by this last numerical field. I can't do: sort -t, -n -k 2 file.in > file.out as the number of fields in each row is not constant. I think sed, awk maybe the ans...

Bidirectionnal Bubble Sort in Java?

I need to implement the bidirectional bubble sort in my code. In other words in will go from left to right first carrying the largest value. But when it reaches out, it should reverse and go from right to left carrying the smallest value. I am advised to to implement another out index in addition the current one. This is what I have...

How can I change an Objects position in a list by changing his content instead of his orderNumber (need an algorithm)?

I'm sorry I couldn't think of a more precise title, but hopefully I'll manage to explain the problem here. I have an Object (DataType) which acts something like the HTML SELECT element, it's a container for predefined values (DataTypeValues) . The values are set in a specific order and in the database, the primary key consists of the Dat...

What type of sort is this?

The C++ book I'm reading described a sort algo, saying it is the Bubblesort yet I cannot find a single variation of bubblesort just like it. I understand the differences are minor, but is it exactly as efficient as a regular bubblesort ? BubbleSort(int A[], int length) for (j=0; j < length-1; j++) for (i=j+1; i < length; i++) if (...

Sorting NSDictionary with multiple constraints

I have a NSDictionary collection whose key is a unique id and value is an array with two different objects (FruitClass, ProductClass) and I would like to group the collection such that it's sorted first by ProductClass.productName and then by FruitClass.itemName. So the final list would look something like: {apple, butter} {apple, pie...

how do i make an html table column sortable in php??

I have an html table that is populated using a text file only and is basically sorted primarily by a timestamp. I would like the option of also sorting the table data by a column ($keys) called "Server" so I can view sorted data based on the server name. Since this is not using mysql and I can't use an 'order by', is there a way to do ac...