diff options
author | Florian Larysch | 2016-01-04 15:48:00 +0100 |
---|---|---|
committer | Florian Larysch | 2016-01-04 15:48:00 +0100 |
commit | 93bf9a1a4124817baa6f9afedda8325c887de723 (patch) | |
tree | 906606968944500d8baa1b1732eef62d0b2bc40d | |
parent | bc853493fa24e4cc573247d943c4efb62b70eabd (diff) |
improve sorting of relive talks
Diffstat (limited to '')
-rw-r--r-- | model/Relive.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/model/Relive.php b/model/Relive.php index 671f1cb..3dfe823 100644 --- a/model/Relive.php +++ b/model/Relive.php @@ -20,10 +20,22 @@ class Relive extends ModelBase $mapping = $this->getScheduleToRoomMapping(); - usort($talks, function($a, $b) { - $sort = array('live', 'recorded', 'released'); - return array_search($a['status'], $sort) > array_search($b['status'], $sort); - }); + usort($talks, function($a, $b) { + // first, make sure that live talks are always on top + if($a['status'] == 'live' && $b['status'] != 'live') { + return -1; + } else if($a['status'] != 'live' && $b['status'] == 'live') { + return 1; + } else if($a['status'] == 'live' && $b['status'] == 'live') { + // sort live talks by room + + return strcmp($a['room'], $b['room']); + } + + // all other talks get sorted by their name + + return strcmp($a['title'], $b['title']); + }); $talks_by_id = array(); foreach ($talks as $talk) |