http://qs1969.pair.com?node_id=281109


in reply to Sorting Criteria

  1. You don't return the elements from the sort block, you return -1, 1 or 0 depending on whether $a or $b was greater or they were equal. See perldoc -f sort.

  2. You don't need to pass $a / $b explicitly that way, they're special globals.

  3. In fact, you even shouldn't, since $a / $b are aliases, and you're reassigning to them a copy of their value at the top of your block. Alternatively, assign them to lexicals named differently from $a / $b. In your case, I'd just drop the shifts, call the function by_date and then say

    @sorted = sort &by_date keys %reversed;

Makeshifts last the longest.