in reply to Help with multidimensional sorting on arrays of hashed arrays
I'm not clear I understand what you want. You say you want to "sort two different arrays together", when it seems (from your code) what you want is to sort the array by two different criteria.
What you get now in @maxtemp are two sorted copies of your @alldata array, first by the first element of the anonymous array referenced by the 'data' key of the anonymous hash, and second by the second element of that anonymous array (oy!).
Do you want to get a list that's ordered by the first element and have 'ties' be sorted by the second element? That looks like
(if the first comparison produces 0, the second comparison will be done)my @maxtemp = sort { $b->{data}[0] <=> $a->{data}[0] or $b->{data}[1] <=> $a->{data}[1] } @alldata;
Deep-nested data structures are pretty complex stuff to be tackling for a self-described 'newbie' =) good on ya!
HTH
Philosophy can be made out of anything. Or less -- Jerry A. Fodor
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Help with multidimensional sorting on arrays of hashed arrays
by Clownburner (Monk) on Mar 10, 2001 at 01:15 UTC | |
by arturo (Vicar) on Mar 10, 2001 at 02:35 UTC | |
by Clownburner (Monk) on Mar 13, 2001 at 00:26 UTC |