From 6250f381d68256f7a23c369d169ad2e103205fed Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sat, 6 Aug 2016 12:46:47 +0200 Subject: sort days in the schedule --- model/Schedule.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'model/Schedule.php') diff --git a/model/Schedule.php b/model/Schedule.php index cc1db55..0b2958e 100644 --- a/model/Schedule.php +++ b/model/Schedule.php @@ -85,8 +85,19 @@ 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']; -- cgit v1.2.3