I'm trying to make an array from a list of records from my database. Making the array is not hard, but I need to order the records from the database in a specific order.
My array (ordered by points):
$all_info[$team_id] = array(
'nickname' => $nickname,
'points' => $points_pr_round,
'time_left' => $time_left,
'total_number' => $points_pr_round + $time_left,
);
More visible example:
$all_info[3] = array(
'nickname' => John,
'points' => 60,
'time_left' => 132,
'total_number' => 60 + 132,
);
$all_info[5] = array(
'nickname' => Victor,
'points' => 78,
'time_left' => 120,
'total_number' => 78 + 120,
);
$all_info[2] = array(
'nickname' => Peter,
'points' => 78,
'time_left' => 125,
'total_number' => 78 + 125,
);
In this case, when I order the array by points
Peter will come first while Victor has a higher response rate.
My question:
How can I order my records, first on points
achieved and if users have the same amount of points the records need to be ordered by response time (time_left
)?