diff options
author | MaZderMind | 2016-08-06 12:46:47 +0200 |
---|---|---|
committer | MaZderMind | 2016-08-06 12:47:26 +0200 |
commit | 6250f381d68256f7a23c369d169ad2e103205fed (patch) | |
tree | a76abed02201f51062476e1bb879b88c292720e6 /model | |
parent | 2bfe55c99cfde006c755af8bc70dd01a6ab3a43c (diff) |
sort days in the schedule
Diffstat (limited to 'model')
-rw-r--r-- | model/Schedule.php | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/model/Schedule.php b/model/Schedule.php index cc1db55..0b2958e 100644 --- a/model/Schedule.php +++ b/model/Schedule.php @@ -85,9 +85,20 @@ class Schedule extends ModelBase $day['end'] = $dayend; } - $dayidx = 0; + + $daysSorted = []; foreach($schedule->day as $day) { + $daysSorted[] = $day; + } + + usort($daysSorted, function($a, $b) { + return (int)$a['start'] - (int)$b['start']; + }); + + $dayidx = 0; + foreach($daysSorted as $day) + { $dayidx++; $daystart = (int)$day['start']; $dayend = (int)$day['end']; |