Schwartzian Transform
en.wikipedia.org
en.wikipedia.org
(sort (compute > score) stories)
If score is expensive, you just wrap it in memo: (sort (compare > (memo score)) stories)
Now it will compute each score once, save them in a table, and throw the table away when done.It seems like an example of the importance and influence of notation - many commonly used languages these days have first class functions but nobody using a lisp-2 variant would have thought to give this particular thing a special name.
http://pgeoghegan.blogspot.com/2015/01/abbreviated-keys-expl...
I've also seen speedups sorting strings by first sorting prefixes of them packed into uint64s (rather than sorting pointer/length references to string data), and in an application where a friend needed to sort a lot of indices into an array, it turned out to greatly speed the sort (by avoiding indirections) to copy the whole array, sort the indices and the copy of the array together, then toss out the copy.
Wouldn't it be embarrassing to have one's name in the title of a long winded Wikipedia article for a super simple and obvious optimization.