[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Omaha.pm] sort hackery
So I've got this array of hashrefs that was built like this:
push @arr, { code=>$prop, desc=>$desc, };
And I want to sort them alphabetically based of desc.
So I do this:
# Sort the list by descriptions
@arr = sort sort_by_desc @arr;
sub sort_by_desc {
$a->{desc} cmp $b->{desc};
}
And it worked, 2nd try.
Yay! It appears I've learned a little Perl over the years. -grin-
Custom sorting methods in Perl rule. Do any other languages allow you to
define custom arbitrary sorting rulesets so easily?
j