Currently I have an array that contains x and y coordinates of various positions.
ex. $location[0]['x'] = 1; $location[0]['y'] = 1
This indicates id 0 has a position of (1,1).
Sometimes I want to sort this array by x, and other times by y.
Currently I am using array-multisort() to sort my data, but I feel this method is inefficient since every time before I sort, I must make a linear pass through the $location array just to build the index (on the x or y key) before I can invoke the array-multisort() command.
Does anyone know a better way to do this? Perhaps it is a bad idea even to store the data like this? Any suggestions would be great.