Generic quicksort library that can be used to sort an array having any data type (int, char *, struct key_value *, etc.).
Amit
amitchoudhary0523@gmail.com
Sat Sep 27 03:42:12 GMT 2025
>
>
> >
> > Mergesort is actually not good compared to quicksort because of memory
> > requirements.
>
> As Adhemerval mentioned the rational can be found in the 'git log' or on
> the mailing list archives [1].
>
> There are programs that expect the sorting to be stable. I have never
> run into a program running out of memory using qsort.
>
> Collin
>
> [1]
> https://inbox.sourceware.org/libc-alpha/a0b8e28438edc5295b33ac280325847314ae7dcc.camel@xry111.site/T/#m2646a2c7a392ef12791a53ddf39db260358768cb
I read this and it mentions both the pros and cons of mergesort. From this,
I gathered that mergesort was done because it is a stable sort.
But this thread also mentions shortcomings of mergesort:
====
The drawback is mergesort requires O(n) extra space, and since it is
allocated with malloc the function is AS-signal-unsafe. It should be
feasible to change it to use mmap, although I am not sure how urgent
it is. The heapsort is also nonstable, so programs that require a
stable sort would still be subject to this latent issue.
====
----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/libc-alpha/attachments/20250927/48c339fa/attachment.htm>
More information about the Libc-alpha
mailing list