I'm looking for a way to sort an array, based on the information in each row, based on the information in certain cells, 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.
<?php
$racers = array('Dygear', 'filur', 'glyphon', 'AndroidXP', 'HorsePower', 'Becky Rose', 'kanutron', 'Victor');
foreach ($racers as $racer)
$query[$racer] = unserialize(file_get_contents('http://lfsworld.net/pubstat/get_stat2.php?version=1.4&ps=1&idk=35cP2S05Cvj3z7564aXKyw0Mqf1Hhx7P&s=2&action=pb&racer='.urlencode($racer)));
foreach ($query as $racer => $data)
{
foreach ($data as $row)
{
if ($row['track'] == '000' && $row['car'] == 'FOX')
$sortArray[$racer] = $row;
}
}
# Sort the Array $sortArray
var_dump($sortArray);
?>