$ perl -we'sub evenfirst ($$) { ($_[0]&1) <=> ($_[1]&1) or $_[0] <=> $_[1] } print sort evenfirst 0..9' 0246813579