On Wed, 2004-06-30 at 14:48, Dave Mitchell wrote: > On Wed, Jun 30, 2004 at 07:58:40PM +0100, Nicholas Clark wrote: > > Does the peephole optimiser currently have any way to optimise > > > > @a = reverse sort @b > > > > into > > > > @a = sort {$b cmp $a} $b; > > > > but without the explicit sort comparison? > > Shouldn't be too difficult. There's some reverse-handling code in pp_sort which I took to be responding to a hint that reverse sort ... has been encountered: 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; } }