in reply to Re^2: sort/reverse strangeness
in thread sort/reverse strangeness

reverse sort is optimized to do the reversing in sort itself, so any difference in speed should be very minor.

Update: Corroboration:

>perl -MO=Concise -e"@b = sort @a" ... 7 <@> sort lK ->8 ... >perl -MO=Concise -e"@b = reverse sort @a" ... 7 <@> sort lK/REV ->8 ...

Update: It turns out that sort simply reverses the array at the end. But because it does so in-place without creating any stack frame, it's faster than reverse.

if (PL_op->op_private & OPpSORT_REVERSE) { SV **p = sorting_av ? AvARRAY(av) : ORIGMARK+1; SV **q = p+max-1; while (p < q) { SV *tmp = *p; *p++ = *q; *q-- = tmp; } }