my @sorted = map { substr $_, 5 } sort { $b cmp $a } map { sprintf '%05d%s', $_ =~ m[,\s+(\d+)], $_ } @msgs;