Greetings! In the train schedule program that you are all probably heartily sick of by now, I have added a ScheduleDay class that represents all trains running on a given day. It has a method that returns an array of references to all of the Train objects for that day. I want to sort those trains on the times people have to show up for them. The Train class has a GetCrewCall() method that returns a string containing the crew call time in HH:MM form, with two digits guaranteed for the hours. Thus, "cmp" will suffice for the comparison. But I'm not sure how to set up the sort. Here's what I have:
sub GetTrainsByTime { my $self = shift; my @result; my @temp; my $aTrain; my $aTrainName; # First we build a temporary array of references to trains foreach $aTrainName (keys $self) { push @temp, $self{aTrainName}; } @result = sort {$a->GetCrewCall() cmp $b->GetCrewCall()} @temp; return @result; } I'm pretty sure this will work, since $a and $b will be references to Train objects, and whatever is inside the brackets is just a plain ordinary block of code. Is this correct? In general, $a and $b are going to be elements of the array being sorted, aren't they? Thanks! Rob, came up with this just before bed and hasn't had time to try it yet. __________________________________________________ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]