How should I sort a doubly linked list the D way?

ikod geller.garry at
Tue Aug 13 12:16:00 UTC 2019

On Tuesday, 13 August 2019 at 09:48:52 UTC, Mirjam Akkersdijk 
> Hello there,
> If I had a DLL, how would I sort it judging by the node 
> contents, the D way?
> In C if I were to sort a piece of malloc'd memory pointing to 
> node pointers, I would write my compare function and let qsort 
> sort it out. In D, I tried to use std.algorithm's sort 
> functionality to no avail, because my guess would be it only 
> operates on arrays. This opens up another can of worms as I am 
> not fond of VLAs and D desperately wants to know what the size 
> is at compile time.

You can check std.container.rbtree which will build sorted "list" 
for you on every Node insert. Again, not sure how this can be 
done at compile time.

More information about the Digitalmars-d-learn mailing list