better name for body of sort
minor optimizations (eliminating intermediate states)
minor additions