Using closures to simplify sorting [1]