in reply to Re: Need to sort and data structure based on values inside arrayrefs.
in thread Need to sort and data structure based on values inside arrayrefs.
But here again, we don't really know what the OP exactly wants to get.use strict; use warnings; my %data = ( A => [ 0, 1, 2, 3, 99, 5, 6 ], B => [ 0, 1, 2, 3, 9.9999, 5, 6 ], C => [ 0, 1, 2, 3, "", 5, 6 ], D => [ 0, 1, 2, 3, undef, 5, 6 ], E => [ 0, 1, 2, 3, 11, 5, 6 ], F => [ 0, 1, 2, 3, 123.0, 5, 6 ], G => [ 0, 1, 2, 3, '', 5, 6 ], H => [ 0, 1, 2, 3, undef, 5, 6 ], I => [ 0, 1, 2, 3, -11, 5, 6 ], J => [ 0, 1, 2, 3, -1.1, 5, 6 ], ); my @rows = sort { (! defined $a->[4]) ? -1 : (! defined $b->[4]) ? 1 : (! length $a->[4]) ? -1 : (! length $b->[4]) ? 1 : ($a->[4] <=> $b->[4]) } values %data;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Need to sort and data structure based on values inside arrayrefs.
by kcott (Archbishop) on Apr 03, 2014 at 13:58 UTC |