Sorting n-dimensional arrays in PHP