Re: Make sorting stable

From: Date: Wed, 11 Mar 2020 15:36:11 +0000
Subject: Re: Make sorting stable
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-108981@lists.php.net to get a copy of this message
> On Mar 4, 2020, at 11:42 AM, Nikita Popov <nikita.ppv@gmail.com> wrote: > > Hi internals, > > Sorting function in PHP currently do not guarantee stability, which means > that the result order of elements that compare equal is not defined. > > .... > > What do people think about this? Is there interest in making sorting > stable? Is it okay to break code using illegal comparison callbacks? I see that most people are okay with the BC breaks on this, and worst case I am okay with them too. However, maybe this is an opportunity to create an object-based interface for array sorting? This could: 1.) Provide the stability guarantee, 2.) Be an object alternate to functions, 3.) Allow for option discovery via auto-complete in IDEs, and 4.) Be easier to remember than the current set of functions. In order to have something for people visualize I created this userland example implementation as a straw man for a potential API that could be provided in core: https://gist.github.com/mikeschinkel/dd22513a23852add93f3817ed9544337 If people like this idea, let's discuss. If not, no need to reply and a lack of interest will signal this is not a direction to pursue. -Mike

« previous php.internals (#108981) next »