#!/usr/bin/perl use strict; use warnings; my $iteration = 0; print sort byStupid (qw(A B C)); sub byStupid { $iteration++; $iteration > 10000 and die "10000 is a lot to sort three things"; if ($b eq 'C' and $a eq 'A') { $b cmp $a; } else { $a cmp $b; } }