sorting std.container
ketmar via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 11 12:07:51 PDT 2016
list slices are not random-access ranges, thus they can't be
sorted in-place (this is what std.algorithm.sort does). so the
only way is to convert list to array, sort it, and make a list
from sorted array. probably not something you want. ;-)
this is common for any "traditional" linked list implementation:
random access is very costly, thus even if it is implemented,
it's better to not use it. SList and DList are "traditional"
lists without any fancy algorithms inside (like finger trees or
skip lists).
you may want to use arrays instead (it is often more efficient
anyway, especially if you don't need to insert elements in the
middle of the array), or associative arrays.
More information about the Digitalmars-d-learn
mailing list