Sort an array