in reply to How do I sort a list chronologically from most recent to last?

This is in perlfaq4, specifically How do I sort an array by (anything)?

In this case, you should probably look into making a more advanced data structure with split or using substr in a more complex sort function. Something like this may work:

my @sorted = sort { substr($a, 0, 4) <=> substr($b, 0, 4) } @unsorted;

This code is untested, suitable only as an example of technique, not syntax.

  • Comment on Re: how do I sort a list chronologically from most recent to last?
  • Download Code