T
Tom Kirchner
hello!
Im currently writing on a part of a program where there is an
array of hash-refs holding data. and I want to sort these
array-elements (the hash-refs) by a first criteria and then
another one. E.g. If each hash would be something like:
@array = (
{ 'name' => 'dan', 'age' => '12', 'shoesize' => '34' },
{ 'name' => 'tom', 'age' => '19', 'shoesize' => '56' },
{ 'name' => 'tom', 'age' => '23', 'shoesize' => '43' },
{ 'name' => 'frank', 'age' => '42', 'shoesize' => '24' },
# ...
);
what I want is: sorting first by 'name' and then, when there
are multiple records with the same name, sorting this (sub)group
by their 'age' and if there are records with the same
name and same age, sorting these by their shoesize.
This is just an example and the real thing is much more
complex, but I need a general idea of how this could be done.
thanks
tom
Im currently writing on a part of a program where there is an
array of hash-refs holding data. and I want to sort these
array-elements (the hash-refs) by a first criteria and then
another one. E.g. If each hash would be something like:
@array = (
{ 'name' => 'dan', 'age' => '12', 'shoesize' => '34' },
{ 'name' => 'tom', 'age' => '19', 'shoesize' => '56' },
{ 'name' => 'tom', 'age' => '23', 'shoesize' => '43' },
{ 'name' => 'frank', 'age' => '42', 'shoesize' => '24' },
# ...
);
what I want is: sorting first by 'name' and then, when there
are multiple records with the same name, sorting this (sub)group
by their 'age' and if there are records with the same
name and same age, sorting these by their shoesize.
This is just an example and the real thing is much more
complex, but I need a general idea of how this could be done.
thanks
tom