my %dow = (qw( Sunday 0 Monday 1 Tuesday 2 Wednesday 3 Thursday 4 Friday 5 Saturday 6 )); # ... $dow{$a[7]} <=> $dow{$b[7]}