Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Notation of sort function

by Jenda (Abbot)
on Oct 28, 2023 at 15:44 UTC ( [id://11155254]=note: print w/replies, xml ) Need Help??


in reply to Notation of sort function

Because we are not just specifying what part(s) of the elements do we want to compare, but also how!

cmp may be fine for you English speaking dudes, but it's basically useless to the rest of the world. Besides even if we did keep to cmp and <=>, what's some other, reasonably succinct and reasonably comprehensible way to write sort {$a->{age} <=> $a->{age} || $b->{name} cmp $a->{name}} @array ?

What is the operation you'd want to apply to the elements so that you can then sort the results using one of the only two types of comparisons you seem to want to get restricted to?

Jenda
1984 was supposed to be a warning,
not a manual!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (2)
As of 2025-11-06 20:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (65 votes). Check out past polls.

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.