Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: Challenge: sort weekdays in week-order (grep)

by LanX (Saint)
on Jul 26, 2022 at 10:17 UTC ( [id://11145739]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Challenge: sort weekdays in week-order (grep)
in thread Challenge: sort weekdays in week-order (elegantly and efficiently)

what about ... :)

DB<189> p "@a" + Monday Tuesday Wednesday Thursday Friday Saturday Sunday DB<190> $a = join "", map { "(?=.*($_))*" } @a DB<191> x grep {defined} "Sunday Friday Monday" =~ /^$a/i 0 'Monday' + 1 'Friday' + 2 'Sunday' + DB<192>

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-19 08:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found