in reply to leaking into sort when sorting an empty set

sort foo('1000');
is the same as
sort foo ('1000');
is the same as
sort foo '1000';
In all of the above, foo is used as the compare function to sort the list consisting of ('1000').

Specifiy a compare function explicitely
sort { $a cmp $b } foo('1000');
or add parenthesises around the arguments to skip the magic
sort(foo('1000'));