You could either sort the students into corresponding times before you start ( a little faster )
or iterate through the array of students 24 times, checking the time each time.
You want to sort the students into there corresponding times
so create arrays of students[24][MAX_STUDENTS]
Then iterate all students and then put each into there corresponding hours.
then you want to iterate through the times in the array 0 - 23
print the time index +1
then iterate through each student in that array (until no more students are left )
and print the name