added a way (beta... still need work) to change the sort order.

This commit is contained in:
2018-12-01 21:08:19 -05:00
parent 6d74d3fbc7
commit 7dd118b0aa
3 changed files with 45 additions and 4 deletions

View File

@@ -102,6 +102,37 @@ class ps4 {
}
function games_reorder($games,$orderby="last_played_desc") {
function totaltime_asc($a,$b) {
return ($a["game_total_time"] <= $b["game_total_time"]) ? -1 : 1;
}
function totaltime_desc($a,$b) {
return ($a["game_total_time"] >= $b["game_total_time"]) ? -1 : 1;
}
function firstplayed_asc($a,$b) {
return ($a["game_played_first"] <= $b["game_played_first"]) ? -1 : 1;
}
function firstplayed_desc($a,$b) {
return ($a["game_played_first"] >= $b["game_played_first"]) ? -1 : 1;
}
function lastplayed_asc($a,$b) {
if ($a["game_played_last"] == -1) { $a["game_played_last"] = (round(microtime(true) * 1000)); }
if ($b["game_played_last"] == -1) { $b["game_played_last"] = (round(microtime(true) * 1000)); }
return ($a["game_played_last"] <= $b["game_played_last"]) ? -1 : 1;
}
function lastplayed_desc($a,$b) {
if ($a["game_played_last"] == -1) { $a["game_played_last"] = (round(microtime(true) * 1000)); }
if ($b["game_played_last"] == -1) { $b["game_played_last"] = (round(microtime(true) * 1000)); }
return ($a["game_played_last"] >= $b["game_played_last"]) ? -1 : 1;
}
usort($games, $orderby);
return $games;
}
}
?>