Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sorting of ordered triples

Status
Not open for further replies.

radzio

Technical User
Aug 10, 2011
7
Hi All,

I got stuck on a quite silly problem but I'm no a programmer and I really need to do it... I have a set of ordered triples (of integer numbers) in a array like:

[tt]h1 k1 l1[/tt]
[tt]k2 k2 l2[/tt]
[tt]...[/tt]
[tt]hN kN lN[/tt]

where N is rather big (lets say more than 200,000). Some triples are the same. How could I sort such list so that the triples of identical indices will be adjacent? I was thinking of radix sort but I have no idea how to write it in a simple way (I'm a beginner user) so it would be as fast as possible.

Thanks a lot for helping me:)

Radek
 
Radix sort seems a good solution to me, this should be an example:

I never used it, but there are also techniques that assign a unique value to a separate set of integers, one unique value per set, I think they're called checksums or so, but I'm not sure at all. It seems more cumbersome than radix sort. Anyway, if you order your array on the checksum, equal checksums should become adjacent after ordering, which gives you an adjacent hi=hj.AND.ki=kj.AND.li=lj.
 
I have found those pages already but the codes there are really hard to modify or use... (as said not really into professional programming). Any deeper explanation how the algorithm may work in my case would be very appreciated:)

Radek
 
Hi,

I managed to calculate some king of checksum for my triples and perform a heap-sort. It works well but I was thinking is is possible to apply something like radix sort and heap-sort together to use only the (h,k,l) indices given.

Thanks in advance,

Radek
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top