Show time ordered entries from midnight at end of loop I'm creating a line up listing page for a festival, across 4 nights. Acts are listed, per day, sorted by a date field in order of a start time field.

The issue I'm having is that midnight until 3am is still considered the night of an event but my time field obviously considers it otherwise.

e.g. an act is performing on the Friday morning at 1am but I need to list this at the end of the Thursday acts.

So the user adds it to the CMS on the Thursday but it appears at the start of the day instead of the end.

Essentially, I just need any acts that appear between 00:00 and 03:00 at the top of a list e.g

Thursday


Act 1 - 1am - 2am
Act 2 - 12am - 1am
Act 3 - 11pm - 12am
Act 4 - 10pm - 11pm


etc

This is the code I have so far

whatDateAreTheyPerforming is a date field

startTime and endTime are time fields

{% set entryIds = craft.entries.section('lineUp').ids() %}
{% set categories = craft.categories.relatedTo({ sourceElement: entryIds }).find() %}

{% for category in categories %}

  {# Fetch all of the entries related to this category #}
  {% set entries = craft.entries.relatedTo(category) %}

  {# Group entries by date and order by start time #}
  {% for date, entries in entries.order('whatDateAreTheyPerforming', 'time(startTime) desc')|
  group('whatDateAreTheyPerforming') %}
    &lt;div&gt;

      &lt;h3&gt;DAY HERE - {{ date | date('l') }} &lt;span&gt;{{ date | date('jS') }}&lt;/span&gt;&lt;/h3&gt;

      &lt;ul&gt;

        {% for entry in entries %}

        &lt;li&gt;
          &lt;h4&gt;{{ entry.title }} 
              &lt;span&gt;{{ entry.whatDateAreTheyPerforming | date('l') }} - {{ entry.startTime | date('G:i') }} - {{ entry.endTime | date('G:i') }}&lt;/span&gt;
          &lt;/h4&gt;
        &lt;/li&gt;

        {% endfor %}

      &lt;/ul&gt;
    &lt;/div&gt;&lt;!-- col --&gt;
  {% endfor %} 

{% endfor %}


I hope this makes sense, any guidance will be appreciated.
I -think- one of the neatest ways to go about this is to introduce a "Show as last in list" lightswitch-field.

I'm currently working on a similar project (festival line-up) where I also needed this; here's the approach I went with.

Basically, I'll be going for two fields: eventTime (date/time-field) and showAsLastInList (lightswitch-field)

{% set events = craft.entries.section('events').showAsLastInList('NOT 1').orderBy('eventTime ASC').all %}

{% for date, eventsByDate in events|group('eventTime|date("Y-m-d")') %}
    {% set additionalEvents = craft.entries.section('events').eventTime(date).showAsLastInList('1').orderBy('eventTime ASC').all %}
    &lt;div class="program__dateline" data-filter-dateline&gt;{{ date|date('l j. F')|capitalize }}&lt;/div&gt;
    {% for event in eventsByDate|merge(additionalEvents) %}
       {# PRINT YOUR HTML HERE #}
    {% endfor %}
{% endfor %}


It's not exactly pretty, but I can't really think of another way to achieve this without creating a custom plugin for it.