in reply to numerical and non numerical sorts
Numeric sorts are done with the <=> operator, string sorts with cmp.
Numeric sort is putting those strings in numeric context where they all evaluate to zero. If you must accomodate both kinds of sort, you could almost use the all-zero property to say
but that would fail, for instance, for strings which look like numbers to perl. It would also sort string representations of numbers according to string rules only if they were numerically the same ( "023" and "2.3e1" would be sorted with "023" first).for my $i (sort { $hash{$b}{$orderby} <=> $hash{$a}{$orderby} || $hash{$b}{$orderby} cmp $hash{$a}{$orderby} } keys %hash) { # do stuff }
If you know enough about your data, that sort rule may be good enough.
After Compline,
Zaxo
|
|---|