Doing this: sort @arrayofnumbers
Same thing: sort {$ a cmp $ b} @arrayofnumbers
Where $ a and $ b are two elements that are compared at each sorting step. The return value of the code block must be an integer, where 0 means the elements are the same, <0 means $ a is less than $ b, a> 0 means $ a is more than $ b. This is usually done using "cmp" for strings and <=> for numbers.
Thus, the part that confuses you, the material between the curly braces, is actually just a block of code that will return -1, 0, or +1 depending on how you want to compare the two elements.
You can do many things there, for example, you can see the order of comparisons by doing something like this:
sort { print "$a cmp $b = ".($a cmp $b)."\n"; return $a cmp $b } (2,19,29,39);
Yielding:
2 cmp 19 = 1
29 cmp 39 = -1
19 cmp 29 = -1
29 cmp 2 = 1
One thing that people get is that the default comparison is string comparison. So if you do this:
print join(',', sort 2,19,39,29)."\n";
You will receive: 19,2,29,39
To perform an integer comparison, you need to do:
sort { $a <=> $b } (2,19,39,29)