Sort a list by comparing the results of a key function applied to each
element.
sortOn f is equivalent to
sortBy (comparing
f), but has the performance advantage of only evaluating
f once for each element in the input list. This is called the
decorate-sort-undecorate paradigm, or Schwartzian transform.
Elements are arranged from lowest to highest, keeping duplicates in
the order they appeared in the input.
>>> sortOn fst [(2, "world"), (4, "!"), (1, "Hello")]
[(1,"Hello"),(2,"world"),(4,"!")]