Fast functional sorting

There is an optimized method to sort a list of items. The method is known in Lisp circles as "decorate-sort-undecorate".

Wikipedia notes that this method is notable for not employing temporary arrays. It shines where items need to be sorted by a particular property, where time could be saved by avoiding computing that property multiple times for each item. It can be related to memoization.

An example of using the transform in practice would be:

To sort the word list ("aaaa","a","aa") according to word length: first build the list (["aaaa",4],["a",1],["aa",2]), then sort it according to the numeric values getting (["a",1],["aa",2],["aaaa",4]), then strip off the numbers and you get ("a","aa","aaaa"). That was the algorithm in general, so it does not count as a transform.

Source: https://en.wikipedia.org/wiki/Schwartzian_transform