Sort uses
cmp when sorting formfields. So numerical formfields get sorted lexically, which is wrong.
Propose to sort using the following sort function instead:
my $number = qr/^[-+]?[0-9]+(\.[0-9]*)?([Ee][-+]?[0-9]+)?$/;
sub _compare {
if( $_[0] =~ /$number/ && $_[1] =~ /$number/ ) {
# when sorting numbers to largets first; this is just because
# this is what date comparisons need.
return $_[1] <=> $_[0];
} else {
return $_[0] cmp $_[1];
}
}
that allows numerical orderings on number data, though it's a bit unpredictable when mixed with lexical data..
--
CrawfordCurrie - 21 Apr 2005