From: Nicholas Clark Date: Fri, 25 May 2001 22:40:19 +0000 (+0100) Subject: Re: stability of sort()? X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c16425f1b01347226d2386c029d71b356d39092d;p=p5sagit%2Fp5-mst-13.2.git Re: stability of sort()? Message-ID: <20010525224019.B86445@plum.flirble.org> p4raw-id: //depot/perl@10215 --- diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index c2b9f39..2fa645d 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -4291,6 +4291,12 @@ loop control operators described in L or with C. When C is in effect, C sorts LIST according to the current collation locale. See L. +Perl does B guarantee that sort is stable. (In a I sort the +relative order is preserved for elements where the sort comparison used +returns that they are equal.) 5.7 happens to use a mergesort, which is +stable, but 5.6 and earlier used quicksort, which is not. However, do not +assume that future perls will continue to use a stable sort such as mergesort. + Examples: # sort lexically