in reply to Sort array according to a value in each element?
I know the rest of the options are better, faster and more flexible, but I think this is simplier.my @items= ( 'Item3 - 1 foo, 3 bar', 'Item1 - 2 foo, 2 bar', 'Item4 - 1 foo, 2 bar', 'Item2 - 0 foo, 1 bar' ); my @sorted = reverse sort map{scalar reverse $_}@items; print scalar reverse $_ . "\n" foreach @sorted;
|
|---|