On Wed, Jun 30, 2004 at 11:42:44AM -0700, Glenn Linderman wrote: > Thanks for describing how one would do this with a modified merge sort. > I agree that there would be some benefits to using merge sort, because > of perl already using mergesort, but I'm uncertain that any of the code > could be reused, without slowing down the "full sort", which wouldn't be > a brilliant thing to do. Indeed not. Slowing down the general case to benefit a special case isn't going to get in. And I've see no evidence to counter my intuition that this case of top M is anything but rare. 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? Nicholas Clark