From Wet Lizard, 10 Years ago, written in Plain Text.
This paste is a reply to sort custom posts by custom meta value data from Dan - go back
Embed
while ($sunday_query->have_posts()) : $sunday_query->the_post();
        
        
{
    $sunday_query->the_post();
    
$sort_array = array();
        
[];
    
$schedules = get_post_meta($post->ID, 'show_sched', false);
        
false);
    
$title = get_the_title();

        foreach($schedules as $schedule):

                $theday = $schedule[0]['day'];
                $theorder = $schedule[0]['start_hour'];

                foreach($schedule as $key => $value):

                        $sort_array[$theorder] = $schedule;

                endforeach;

    endforeach;

        ksort($sort_array, SORT_NUMERIC);

        
get_the_title();
    
    usort($schedules, function ($a, $b) {
        return $a[0]['start_hour'] > $b[0]['start_hour'] ? 1 : -1;
    });

    array_filter($schedules, function ($schedule) {
        return $schedule['day'] === 'Sunday';
    }

    
foreach($sort_array as $sort) {
                
{
        
foreach($sort as $key => $value) {
                        
{
            
$day = $value['day'];
                        
$value['day'];
            
$order = $value['start_hour'];
                        if($day == 'Sunday') {
                                
$value['start_hour'];
            
            
echo $day.', '.$order.' . $order . ', '.$title;
                                echo '<br>';
                        }
                }
        }

endwhile;
' . $title . '<br>';
        }
    }
}