in reply to Challenge: sort weekdays in week-order (elegantly and efficiently)
I agree with the others that using a module like Time::Piece, DateTime, or at least Sort::Key is the right way to go about this. But just for fun, TIMTWOTDI, and to fulfill your "some kind of transform" idea:
use List::Util qw/shuffle/; my @weekdays = shuffle qw/ Monday Tuesday Wednesday Thursday Friday Saturday Sunday /; say join ", ", map { $$_[0] } sort { $$a[1] cmp $$b[1] } map { [$_, lc(substr $_,0,2)=~tr/softwarehum/50411307860/r] } @weekdays;
Update: Anagram'd
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Challenge: sort weekdays in week-order (elegantly and efficiently)
by tybalt89 (Monsignor) on Jul 22, 2022 at 14:58 UTC | |
by roho (Bishop) on Jul 23, 2022 at 21:45 UTC | |
by tybalt89 (Monsignor) on Jul 23, 2022 at 22:40 UTC | |
by rsFalse (Chaplain) on Jul 25, 2022 at 22:51 UTC | |
by roho (Bishop) on Jul 24, 2022 at 02:06 UTC |