The only thing I would add is that you seem to wonder about
the sort order. That's addressed in the sort
documentation; it defaults to a string comparison (cmp)
but your example uses a numeric comparison (<=>).
See perlop for documentation of these operators.