www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - array.sort - What algorithm is being used here?

reply "Daniel Harper" <djharperuk gmail.com> writes:
It's not clear in the documentation 
(http://dlang.org/arrays.html) what sorting algorithm is being 
used behind the array.sort implementation.

Can anyone shed any light? I.e. is it quicksort?
Sep 16 2012
parent reply "jerro" <a a.com> writes:
On Sunday, 16 September 2012 at 20:29:50 UTC, Daniel Harper wrote:
 It's not clear in the documentation 
 (http://dlang.org/arrays.html) what sorting algorithm is being 
 used behind the array.sort implementation.

 Can anyone shed any light? I.e. is it quicksort?
It is. The source is here https://github.com/D-Programming-Language/druntime/blob/master/src/rt/qsort.d . You should probably be using std.algorithm.sort, though.
Sep 16 2012
parent reply "Daniel Harper" <djharperuk gmail.com> writes:
On Sunday, 16 September 2012 at 20:52:03 UTC, jerro wrote:
 On Sunday, 16 September 2012 at 20:29:50 UTC, Daniel Harper 
 wrote:
 It's not clear in the documentation 
 (http://dlang.org/arrays.html) what sorting algorithm is being 
 used behind the array.sort implementation.

 Can anyone shed any light? I.e. is it quicksort?
It is. The source is here https://github.com/D-Programming-Language/druntime/blob/master/src/rt/qsort.d . You should probably be using std.algorithm.sort, though.
Thanks for the prompt reply. Perhaps the documentation can be updated to reflect this?
Sep 16 2012
parent reply deadalnix <deadalnix gmail.com> writes:
Le 17/09/2012 00:29, Daniel Harper a écrit :
 On Sunday, 16 September 2012 at 20:52:03 UTC, jerro wrote:
 On Sunday, 16 September 2012 at 20:29:50 UTC, Daniel Harper wrote:
 It's not clear in the documentation (http://dlang.org/arrays.html)
 what sorting algorithm is being used behind the array.sort
 implementation.

 Can anyone shed any light? I.e. is it quicksort?
It is. The source is here https://github.com/D-Programming-Language/druntime/blob/master/src/rt/qsort.d . You should probably be using std.algorithm.sort, though.
Thanks for the prompt reply. Perhaps the documentation can be updated to reflect this?
I'd argue that .sort must be blasted out of existence.
Sep 16 2012
parent reply Jonathan M Davis <jmdavisProg gmx.com> writes:
On Monday, September 17, 2012 00:42:40 deadalnix wrote:
 I'd argue that .sort must be blasted out of existence.
I can't remember if it was agreed that it should be deprecated or not. Too many items like that are _supposed_ to be deprecated (with Walter's full agreement) but still persist, but I don't remember if Walter agreed to axe this one or not. I definitely think that it should go though. - Jonathan M Davis
Sep 16 2012
parent "Peter Alexander" <peter.alexander.au gmail.com> writes:
On Monday, 17 September 2012 at 00:09:36 UTC, Jonathan M Davis 
wrote:
 On Monday, September 17, 2012 00:42:40 deadalnix wrote:
 I'd argue that .sort must be blasted out of existence.
I can't remember if it was agreed that it should be deprecated or not. Too many items like that are _supposed_ to be deprecated (with Walter's full agreement) but still persist, but I don't remember if Walter agreed to axe this one or not. I definitely think that it should go though. - Jonathan M Davis
It's on the deprecated list (3rd from bottom): http://dlang.org/deprecate.html No schedule for deprecation though. Just says "future".
Sep 16 2012