Skip to content

Commit

Permalink
Sort talks by track ID if one exists within a time slot for more stab…
Browse files Browse the repository at this point in the history
…le sorting
  • Loading branch information
iansltx committed Aug 10, 2021
1 parent 19d920e commit dc5e9f6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app/src/Event/EventScheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Event;

use Talk\TalkApi;
use Talk\TalkEntity;

/**
* Class EventScheduler
Expand Down Expand Up @@ -83,13 +84,19 @@ public function getEventDays($talks)
* associative array by day, then by time for each
* day
*
* @param array $talks
* @param TalkEntity[] $talks
* @return array
*/
protected function organiseTalksByDayAndTime($talks)
{
$talksByDay = [];

usort($talks, function (TalkEntity $a, TalkEntity $b) {
return $a->getTracks() && $b->getTracks()
? strcasecmp($b->getTracks()[0]['track_uri'], $a->getTracks()[0]['track_uri'])
: $b['id'] <=> $a['id'];
});

foreach ($talks as $talk) {
$dateTime = $talk->getStartDateTime();
$date = $dateTime->format('d-m-Y');
Expand Down

0 comments on commit dc5e9f6

Please sign in to comment.