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

Re: (Ovid) Re: Can Schwartzian transform be modified to sort an arrayref uniquely?

by gbarr (Monk)
on Jan 05, 2002 at 01:24 UTC ( [id://136386]=note: print w/replies, xml ) Need Help??


in reply to (Ovid) Re: Can Schwartzian transform be modified to sort an arrayref uniquely?
in thread Can Schwartzian transform be modified to sort an arrayref uniquely?

One of the "features" of the Schwartzian transform is that you don't have to create any named temporary variables. So instead of using %saw or $prev you could do

my $data = [ { num => 'OF1234', title => 'title OF1234', }, { num => 'AF1234', title => 'title AF1234', }, { num => 'AF1234', title => 'title AF1234', }, ]; my @sorted = sort { $a->{num} cmp $b->{ num } } values %{ +{ map { ($_->{num},$_) } @$data }}; print join ', ', map { $_->{num} } @sorted;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2024-04-23 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found