How should I sort a doubly linked list the D way?
noreply at noreply.com
Tue Aug 13 17:33:10 UTC 2019
On Tuesday, 13 August 2019 at 14:04:45 UTC, Sebastiaan Koppe
> On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk
>> and I would like to sort based on Node.t, how should I tackle
>> it, preferably without resorting to C libraries?
> Convert the nodes into an D array, sort the array with
> nodes.sort!"a.x < b.x" and then iterate the array and repair
> the next/prev pointers.
Thank you, this is what I eventually chose to do. It's also
fairly fast, though doesn't the nature of the dynamic array slow
it down a bit? Since I already know the size of the array (but
just not at compile time), can't I define an array of fixed size,
which is dependent on the input of the function?
More information about the Digitalmars-d-learn