improve c986717 a bit

use array_walk and an anonymous function for the sort