Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Challenge: sort weekdays in week-order (elegantly and efficiently)

by tybalt89 (Monsignor)
on Jul 21, 2022 at 15:49 UTC ( [id://11145639]=note: print w/replies, xml ) Need Help??


in reply to Challenge: sort weekdays in week-order (elegantly and efficiently)

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11145633 use warnings; use List::AllUtils qw( nsort_by ); my @weekdays = qw/Monday Saturday Thursday/; print "$_\n" for nsort_by { 'motuwethfrsasu' =~ substr lc, 0, 2; $-[0] } @weekdays;

Outputs:

Monday Thursday Saturday

Log In?
Username:
Password:

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

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

    No recent polls found