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

Coming directly to you from the Horrible-But-Works department is this monstrosity:

#!/usr/bin/env perl use strict; use warnings; use Digest::SHA 'sha512256_hex'; my @weekdays = qw/Monday Saturday Thursday/; print join ",", map { $_->[0] } sort { $a->[1] cmp $b->[1] } map { [$_, substr (sha512256_hex (substr (lc ($_), 1, 7)), 26, 1)] } @ +weekdays;

🦛

  • Comment on Re: Challenge: sort weekdays in week-order (elegantly and efficiently)
  • Download Code