Re: hash of arrays sorting

2012-08-23 Thread Salvador Fandino
> IIRC, a long time ago I send you a patch for Sort::Maker benchmarking > script incorporating Sort::Key variants that showed how faster my module > can be. I would try to find it and send it to you again. Well, I have been unable to find it... but I have redone it :-) Attached are the patch tha

Re: hash of arrays sorting

2012-08-23 Thread Salvador Fandino
On 08/23/2012 09:10 AM, Uri Guttman wrote: > On 08/23/2012 02:54 AM, Salvador Fandino wrote: > >>> >>> It's a pity Sort::Maker not in Debian >> >> There is also Sort::Key, available in Debian testing and unstable, and >> which is usually faster than Sort::Maker and also Sort::Key::Radix, even >> f

Re: hash of arrays sorting

2012-08-23 Thread Rob Coops
On Thu, Aug 23, 2012 at 9:10 AM, Uri Guttman wrote: > On 08/23/2012 02:54 AM, Salvador Fandino wrote: > > >>> It's a pity Sort::Maker not in Debian >>> >> >> There is also Sort::Key, available in Debian testing and unstable, and >> which is usually faster than Sort::Maker and also Sort::Key::Radi

Re: hash of arrays sorting

2012-08-23 Thread Uri Guttman
On 08/23/2012 02:54 AM, Salvador Fandino wrote: It's a pity Sort::Maker not in Debian There is also Sort::Key, available in Debian testing and unstable, and which is usually faster than Sort::Maker and also Sort::Key::Radix, even faster when sorting by numeric keys but not available in Debian

Re: hash of arrays sorting

2012-08-22 Thread Salvador Fandino
On 08/22/2012 10:34 PM, Eduardo wrote: > On 22/08/12 03:49, Uri Guttman wrote: >> On 08/21/2012 08:29 PM, Eduardo wrote: >>> how would you do with Sort::Maker? >> i don't have time to show an example now but it is much cleaner >> looking. all you need to do is code up how you extract each key from

Re: hash of arrays sorting

2012-08-22 Thread Eduardo
On 22/08/12 03:49, Uri Guttman wrote: > On 08/21/2012 08:29 PM, Eduardo wrote: >> how would you do with Sort::Maker? > i don't have time to show an example now but it is much cleaner > looking. all you need to do is code up how you extract each key from > the data set and how it gets sorted (number

Re: hash of arrays sorting

2012-08-21 Thread Uri Guttman
On 08/21/2012 08:29 PM, Eduardo wrote: On 22/08/12 00:35, Uri Guttman wrote: my %cache = (); foreach ( keys %$hash ) { my ( $naa, $nab ) = $_ =~ m|^(\d+)-(\d+)|; $cache{ ($naa * 100 + $nab ) } = $_; } that is a variant of the orcish manoever which is supported by sort::maker. fore

Re: hash of arrays sorting

2012-08-21 Thread Eduardo
On 22/08/12 00:35, Uri Guttman wrote: > On 08/21/2012 05:33 PM, Eduardo wrote: >> On 21/08/12 22:05, Chris Stinemetz wrote: >>> Hello List, >>> >>> I am trying to sort a hash of arrays ( example below: ) >>> >>> I would the sort to sort in ascending order the first index of the >>> array >>> then

Re: hash of arrays sorting

2012-08-21 Thread Uri Guttman
On 08/21/2012 05:33 PM, Eduardo wrote: On 21/08/12 22:05, Chris Stinemetz wrote: Hello List, I am trying to sort a hash of arrays ( example below: ) I would the sort to sort in ascending order the first index of the array then the second index of the array. So in this example the arrays wou

Re: hash of arrays sorting

2012-08-21 Thread Eduardo
On 21/08/12 22:05, Chris Stinemetz wrote: > Hello List, > > I am trying to sort a hash of arrays ( example below: ) > > I would the sort to sort in ascending order the first index of the array > then the second index of the array. > > So in this example the arrays would sort to: > > 97,2,120,65 >

Re: hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
I will leave it to you to write an actual program incorporating these > ideas. > > Thank you Jim for the excelent explanation. This seems to do the trick. foreach my $cellNo ( sort { $hash{$a}->[0] <=> $hash{$b}->[0] || $hash{$a}->[1] <=> $hash{$b}->[1] } keys %hash ) { print join( "\0", @{

Re: hash of arrays sorting

2012-08-21 Thread Jim Gibson
On Aug 21, 2012, at 1:23 PM, Jim Gibson wrote: > > On Aug 21, 2012, at 1:05 PM, Chris Stinemetz wrote: > >> Hello List, >> >> I am trying to sort a hash of arrays ( example below: ) >> >> I would the sort to sort in ascending order the first index of the array >> then the second index of the

Re: hash of arrays sorting

2012-08-21 Thread Jim Gibson
On Aug 21, 2012, at 1:05 PM, Chris Stinemetz wrote: > Hello List, > > I am trying to sort a hash of arrays ( example below: ) > > I would the sort to sort in ascending order the first index of the array > then the second index of the array. I believe you mean "first element" rather than "first

Re: hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
On Tue, Aug 21, 2012 at 3:11 PM, Shawn H Corey wrote: > On Tue, 21 Aug 2012 15:05:33 -0500 > Chris Stinemetz wrote: > > > I am trying to sort a hash of arrays ( example below: ) > > > > I would the sort to sort in ascending order the first index of the > > array then the second index of the array

Re: hash of arrays sorting

2012-08-21 Thread Shawn H Corey
On Tue, 21 Aug 2012 15:05:33 -0500 Chris Stinemetz wrote: > I am trying to sort a hash of arrays ( example below: ) > > I would the sort to sort in ascending order the first index of the > array then the second index of the array. What have you tried so far? Can we see the code? -- Just my 0

hash of arrays sorting

2012-08-21 Thread Chris Stinemetz
Hello List, I am trying to sort a hash of arrays ( example below: ) I would the sort to sort in ascending order the first index of the array then the second index of the array. So in this example the arrays would sort to: 97,2,120,65 219,1,30,33 280,3,230,90 462,2,270,65 $VAR1 = { '