So you found the line:
@{$Grid->{'grid'}->[$y]->[$x]->{'events'}} = sort { ($a->{'schedule'}->{'start'} <=> $b->{'schedule'}->{'start'}) | | ($a->{'details'}->{'id'} <=> $b->{'details'}->{'id'}) } @{$Grid->{'grid'}->[$y]->[$x]->{'events'}};
The general for of that line looks this:
@array = sort {
#return -1 if $a < $b, 0 if $a == $b, and 1 if $a > $b
} @array;
So you are basically passing an inline subroutine to sort, followed by an array you want sorted. The sort function invokes the subroutine with $a and $b being two items in the array that need comparing. Also, Perl is nice enough to provide the <=> (numbers) and the cmp (strings) functions that return -1, 0, or 1 as specified above. Finally, if you don't provide a return statement, Perl returns the value of the last statement.
Now that you've got the general knowledge, here's how you would sort by Chapter, then start time:
@{$Grid->{'grid'}->[$y]->[$x]->{'events'}} = sort { ($a->{'details'}->{'chapter'} cmp $b->{'details'}->{'chapter'}) | | ($a->{'schedule'}->{'start'} <=> $b->{'schedule'}->{'start'}) | | ($a->{'details'}->{'id'} <=> $b->{'details'}->{'id'}) } @{$Grid->{'grid'}->[$y]->[$x]->{'events'}};
When I post that, the UBB is probably going to put a space between the to pipes ( | | ). You'll need to remove the space. So the above routine will compare to events by chapter (using cmp since I assume they are strings), then by time, and if you happen to have two things in the same chapter at the same time, by id.
Hope that helps.
------------------
David Whittaker
http://www.uabcm.com/
http://www.csworkbench.com/