B
Brett
Jürgen Exner said:Indeed, there is: use a data structure that matches your problem better.
Instead of having a pair of unrelated arrays use a single array of pairs.
And then sort that single array by the value of the first component of each
pair.
jue
I'm new to this, and tried to give it a go.
use Class::Struct;
struct ID =>
{
number => '$',
name => '$',
};
my @IDs = ID->new();
#fill data...
@IDs = sort {$a->number <=> $b->number} (@IDs); # numeric sort on number
but that failed to sort the list as i expected. How can i use sort on a
structure to do
what I want?