Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

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

by tybalt89 (Monsignor)
on Jul 21, 2022 at 15:49 UTC ( #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? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2022-12-09 17:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?