http://www.perlmonks.org?node_id=11134278


in reply to Re^2: How can I do a numeric sort on a substring?
in thread How can I do a numeric sort on a substring?

in case there are more than one number matching like a-1-3 ?

Do you mean something like Sort::Key::Natural? See also How do I do a natural sort on an array?

  • Comment on Re^3: How can I do a numeric sort on a substring?

Replies are listed 'Best First'.
Re^4: How can I do a numeric sort on a substring?
by LanX (Saint) on Jun 25, 2021 at 16:48 UTC
    Thanks for pointing to Sort::Key , seems it covers all use cases of the Schwartzian transform with a short syntax. :)

    The documentation could be simpler tho, by deconstructing the naming convention.

    [|r][|n|i|u]keysort[_inplace] @array

    (Like this the doc seem even to be not logical/ wrong in one case)

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Re^4: How can I do a numeric sort on a substring?
by misterperl (Pilgrim) on Jun 25, 2021 at 14:15 UTC
    sort key natural IS DA BOMB!! TY TY this made my week :)
Re^4: How can I do a numeric sort on a substring?
by misterperl (Pilgrim) on Jun 25, 2021 at 14:09 UTC
    I never saw that Natural sort- you are on fire today all ++ votes! TYVM Have a great weekend- I'm headed off to study your suggestions..
      For an even more general sort, see the function 'sort_by' in List::UtilsBy.
      Bill
        No, no!!!

        Sort::Key family of modules is far more general and flexible than List::UtilsBy::sort_by!