in reply to Re: Sorting numerials first and then numerials with alpha characters last
in thread Sorting numerials first and then numerials with alpha characters last

That code assumes sort is stable. Use use sort 'stable'; to guarantee that.

Replies are listed 'Best First'.
Re^3: Sorting numerials first and then numerials with alpha characters last
by Anonymous Monk on Oct 29, 2021 at 18:35 UTC
    That code assumes sort is stable. Use use sort 'stable'; to guarantee that.

    what?

      Chaining sorts only works for stable sorts. What is stability in sorting algorithms and why is it important?

      Perl's sort isn't even stable in all versions of Perl, so the solution won't work in all existing versions of Perl.

      Perl's sort isn't guaranteed to be a stable sort, so the solution isn't guaranteed to work in future versions of Perl.

      But, you can tell sort to use a stable algorithm using use sort 'stable';.

        Chaining sorts

        read the code again