in reply to sorting two arrays together
In case you don't have a compelling reason to hold the data in two separate arrays, you could maybe also store the pairs as subarrays in one array:
my @a = ([92,60], [6,5], [2,12]); my @sorted = sort { $a->[0] <=> $b->[0] } @a; # result: ([2,12], [6,5], [92,60])
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting two arrays together
by JavaFan (Canon) on Dec 22, 2010 at 22:49 UTC | |
by Anonyrnous Monk (Hermit) on Dec 22, 2010 at 23:38 UTC | |
by JavaFan (Canon) on Dec 22, 2010 at 23:49 UTC | |
by Anonyrnous Monk (Hermit) on Dec 23, 2010 at 00:11 UTC | |
by BrowserUk (Patriarch) on Dec 23, 2010 at 01:19 UTC | |
| |
|
Re^2: sorting two arrays together
by siskos1 (Acolyte) on Dec 22, 2010 at 22:28 UTC |