in reply to Re^3: Sorting files by 3 numbers in the name
in thread Sorting files by 3 numbers in the name

> We are comparing fixed length strings of digits

I haven't seen that guaranteed, so I prefer playing safe.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Je suis Charlie!

  • Comment on Re^4: Sorting files by 3 numbers in the name

Replies are listed 'Best First'.
Re^5: Sorting files by 3 numbers in the name
by BillKSmith (Monsignor) on May 28, 2017 at 15:15 UTC

    Unfortunately, your suggestion is not much safer. It will help only if the first field is the only one that is not of fixed length.

    Either sort should work with tobyink's suggestion to replace the join with sprintf. You can think of the result as a number formed by multiplying each field by different power of ten and then adding them.

    Bill
      Good spot!

      ... hmm maybe a valid feature request to allow array-refs in sort_by, such that all fields are compared in an or chain.

      Cheers Rolf
      (addicted to the Perl Programming Language and ☆☆☆☆ :)
      Je suis Charlie!