I would like the sort option of either QuickSort (unstable, in-place) or MergeSort for arrays.
I've coded a MergeSort routine in VB6, but it can't be faster than you guys.

See hereFreak wrote:Since PB 4.30, SortStructuredList (and SortList) use Mergesort which is a stable sort, so if you first sort all the list by titles and then again by album you will get a list which is sorted by album and each album is sorted by title.
Note that this does not work with Arrays, as SortArray uses Quicksort which is unstable. (ie the sorting of the secondary key would be lost)
Freak knows the system better than you do!Fred wrote:My bad, it's QuickSort for Array and MergeSort for lists.
I have a PureBasic MergeSort (stable and in place) that is written for dynamic arrays (structured). If you would like it just let me know a few specifics about your needs and I can modify it so it will to make sure it's in line with what you need.skywalk wrote:Okay?
So who is correct?
I guess I will do a test to prove stability, but lots to do and a manual/forum update would be faster.
My mergesort isn't in ASM either. It is roughly 3 - 5 times slower than PureBasic's QuickSort. I did the test with 50000 items in a structured array, it took 16.6 ms for PB's QuickSort and 70.4 ms for my mergesort. Because of the overhead (recursive procedure calls) it tends to increase in time according to the number of things in the array. For instance, with 5000000 it was about 8.5x slower.skywalk wrote:Thanks very much, Demivec, I didn't see your offer until now.
My mergesort is not in ASM so it probably can't compare in speed.
I'll definitely look at your implementation before final design.