On Mar 2, 2005, at 12:14 AM, John Horner wrote:

@data = sort {
    $a->{year} <=> $b->{year}
      ||
    $months{ $a->{month} } <=> $months{ $b->{month} }
} @data;

## only if the years are equal does the second sort take place, is that right?

Yes - when you use ||, it "short circuits" the expression if the first part is true. Conversely, when you use &&, it "short circuits" if the first part is false.


sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org



Reply via email to