Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Sorting numerials first and then numerials with alpha characters last

by ikegami (Patriarch)
on Oct 29, 2021 at 18:27 UTC ( [id://11138222]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11138222]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-03-28 18:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found