Array sorting

Array sorting

Hi
I need to sort the lines of a nx4 array, using the values of a column as the sorting parameter. The subs I found
in documentation are for one dimension arrays.
Can anyone help, indicating were can I find a subroutine that sorts a n x m array?
Thanks
Geraldo

4 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi,
You didn't specify if the subsequent values in the first dimension are to be sorted subordinately to the prior ones. There are straightforward algorithims (see, e.g. Numerical Receipes, Press, et al.) in which one sorts an array whose sequential values contain the sequence number of the entry in the object array, were it sorted. This has the advantage that the entries in the array don't have to be moved.
Keith

I use Michel Olagnon's sorting routines -- particularly, see MRGRNK, which doesn't sort but returns a rank array instead; you can use that to renumerate all items. You could possibly also try some qsort (QSORT or SORTQQ), basically treating the matrix as array of 4-byte structures.

Jugoslav

Jugoslav
www.xeffort.com

Thanks Keith and Yugoslav.
I downloaded Orderpack, and will access Numerical Recipes ( I had it in my bookmarks but have never accessed it).
Will take some time to digest it all.
Geraldo

Leave a Comment

Please sign in to add a comment. Not a member? Join today