in reply to sorting numbered words

You could use a Schwartzian Transform:
@sorted = map {$_->[2]} sort {$a->[0] cmp $b->[0] || $a->[1] <=> $b->[1]} map {/(\D+)(\d+)/;[$1,$2,$_]} @unsorted;

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}

Replies are listed 'Best First'.
Re^2: sorting numbered words
by Anonymous Monk on Dec 18, 2006 at 14:37 UTC
    this fails on files named like "test69.something-14-14"

      If my example doesn't work for you, modify it accordingly.

      That said, I don't see how it fails (as I don't know what you expect):

      #!/usr/bin/perl -w use strict; my @unsorted = <DATA>; my @sorted = map {$_->[2]} sort {$a->[0] cmp $b->[0] || $a->[1] <=> $b->[1]} map {/(\D+)(\d+)/;[$1,$2,$_]} @unsorted; print for @sorted; __DATA__ test69.something-14-14 test28.something-14-14 foo52.something-14-14 test13.something-14-14 test4.something-14-14 foo58.something-14-14 test31.something-14-14 test15.something-14-14 test59.something-14-14 foo5.something-14-14 test41.something-14-14 test38.something-14-14 foo11.something-14-14 test10.something-14-14 test8.something-14-14 test49.something-14-14 foo24.something-14-14 foo7.something-14-14 bar27.something-14-14 bar0.something-14-14 test3.something-14-14 __END__ bar0.something-14-14 bar27.something-14-14 foo5.something-14-14 foo7.something-14-14 foo11.something-14-14 foo24.something-14-14 foo52.something-14-14 foo58.something-14-14 test3.something-14-14 test4.something-14-14 test8.something-14-14 test10.something-14-14 test13.something-14-14 test15.something-14-14 test28.something-14-14 test31.something-14-14 test38.something-14-14 test41.something-14-14 test49.something-14-14 test59.something-14-14 test69.something-14-14

      The OP didn't

      1. contain filenames like "test69.something-14-14"
      2. specifiy that filenames as a composite of any number of fields of strings and digits were to be sorted string- and number-wise
      3. specify how non-letter and non-digits should be treated.

      Bug reports without logs are useless.

      Further recommended reading: I know what I mean. Why don't you?

      --shmem

      _($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                                    /\_¯/(q    /
      ----------------------------  \__(m.====·.(_("always off the crowd"))."·
      ");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}