Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
I use the sort function to order an array of filenames alphabetically; for example:
@names = ( "FLY_ABC123_01.jpg", "PG_ABC123_03", "SPL_ABC123_02.jpg" );
The normal sort function can return the files in ascending alphabetical order, which would be: FLY_ABC123_01.jpg, PG_ABC123_03.jpg, SPL_ABC123_02.jpg.
However, I would like to sort these filenames based on the number after the last underscore (e.g. "_01"). Is there any way to do this?
I guess one option would be to ignore the characters before the first underscore (e.g. "FLY_").
Thanks,
Ralph
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Sorting filenames with custom function
by kennethk (Abbot) on May 13, 2010 at 18:57 UTC | |
by AnomalousMonk (Archbishop) on May 13, 2010 at 22:10 UTC | |
by kennethk (Abbot) on May 13, 2010 at 22:44 UTC | |
by AnomalousMonk (Archbishop) on May 14, 2010 at 02:06 UTC | |
|
Re: Sorting filenames with custom function
by AR (Friar) on May 13, 2010 at 18:50 UTC | |
|
Re: Sorting filenames with custom function
by Marshall (Canon) on May 13, 2010 at 22:17 UTC | |
|
Re: Sorting filenames with custom function
by Anonymous Monk on May 14, 2010 at 18:37 UTC |