Generate list of events, sorted by date and time

I need to generate a list of events (out of subpages), sorted by start date, end date and start time (with the date as headline for each day), wich is working so far. A subpage can actually have up to 5 events (each with start date, end date and start time). I just manage to filter and sort them with 1 event – is there a clever way to do this for all 5 events over all subpages ?
Thanks a lot in advance !


    label: Start Date
    type: date
    format: DD/MM/YYYY
    label: End Date
    type: date
    format: DD/MM/YYYY
    label: Time Start
    type: time
    format: 24
    label: Time End
    type: time
    format: 24



// Set collection of events
$events = $pages->find('projekte')->children()->visible()->sortBy('date', 'dateStart1', 'asc')->sortBy('timeStart1', 'asc');
// Set start date an duration for time span
$startDate = '01.11.2018';
$days = 18;
// Set counter for days
$i = 0;

//Count up days and date until $days is reached
while($i < $days) {
  $date = date('d.m.Y', strtotime($startDate. ' + ' . $i++ . 'days'));
  // Set counter for $headline, 0 = create headline
  $headline = 0;
  // Display and sort events by start/end date and start/end time  -->
  foreach($events as $event) {
    // Check if event is taking place this day
    if($event->date('d.m.Y', 'dateStart1') == $date || $event->date('d.m.Y', 'dateStart1') <= $date && $event->date('d.m.Y', 'dateEnd1') >= $date){
      // Create headline if first event of day
      if($headline == 0) {
        echo "<hr />";
        echo "<b>" . $date . "</b><br />";
      // Set counter for $headline to 1 = don't create headline
      $headline = 1;
      // Display start time, end time, title
      echo $event->timeStart1()->html();
        echo "—" . $event->timeEnd1()->html();
      echo ", ". $event->title()->html() . "<br />";

Why do you use these named fields instead of a structure field for repeated fields?

I. assume those events in a single subpage are just different dates of the same event while each subpage is a different event?

In any case I would first create a collection of all these events, then sort them by date and finally groupBy() date.