Sorting Arrays by More the One Value, and Prioritizing the Sort based on Column data.
- by Mark Tomlin
I'm looking for a way to sort an array (we call this a row), with an array of values (that I'll call columns).
Each row has columns that must be sorted based on the priority of: timetime, lapcount & timestamp.
Each column cotains this information: split1, split2, split3, laptime, lapcount, timestamp.
laptime if in hundredths of a second. (1:23.45 or 1 Minute, 23 Seconds & 45 Hundredths is 8345.) Lapcount is a simple unsigned tiny int, or unsigned char. timestamp is unix epoch.
The lowest laptime should be at the get a better standing in this sort. Should two peoples laptimes equal, then timestamp will be used to give the better standing in this sort. Should two peoples timestamp equal, then the person with less of a lapcount get's the better standing in this sort.
By better standing, I mean closer to the top of the array, closer to the index of zero where it a numerical array.
I think the array sorting functions built into php can do this with a callback, I was wondering what the best approch was for a weighted sort like this would be.