First you do a numeric sort. In this case, undef and the
strings take on the value zero in a numeric context. Thus,
0, undef, 'aaa', 'AAA', 'ZZZ' and 'zzz' all compare equally
and come before the >0 numbers.
Then for all the ones above that are numerically equivalent to 0, you do a
string comparison; now in string cxontext, undef is treated as the empty
string "" and 0 is treated as the one character string "0".
Thus they get sorted as undef, 0, AAA, ZZZ, aaa, zzz.
Running with warnings enabled might be illuminating at this point.
Dave.