http://www.perlmonks.org?node_id=1018626


in reply to Sorting complex data

To clarify the above ... the sort verb allows a comparison subroutine to be specified.   That can be as simple as the “one-liner” in-between (and including) the curly braces, which uses the <=> operator designed expressly for this purpose, or it can be a much more complicated function.   Within that function, for your further convenience, the variables $a and $b are magically defined.