A solution to http://cacm.acm.org/magazines/2014/5/174346-puzzled-a-sort-of-sorts