in reply to Challenge: sort weekdays in week-order (elegantly and efficiently)
use v5.12; use warnings; use Sort::Key qw/ikeysort/; use Data::Dump qw/pp dd/; my $n; my %order = map {$_ => ++$n} qw/monday tuesday wednesday thursday friday saturday sunday/; pp ikeysort { $order{lc($_)} } qw/Monday Saturday Thursday/;
==>
("Monday", "Thursday", "Saturday")
Fixed bug in %order creation
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|