More stability to sort can be added with compare function I made something like this :
if a.x = b.x then Result := CompareObjectPointerValues(a, b);
So as last resort I compared the Raw pointers of the objects, and they should always be different (if the implementation will not use duplicate objects references)
Been using merge sort for a while, which seems to hold its own against timsort: http://gamasutra.com/view/news/172542/Indepth_Smoothsort_vs_Timsort.php#.URsHjBG9KSM I'm not convinced being fast on already sorted arrays is such a great advantage, usually that's handled by flagging, on partially sorted arrays, timsort & merge sort are similar, and on random arrays timsort is worse. So not convinced the greater complexity (and potential for bugs) of timsort is really worth it.
This would be interesting, if there would be good implementation on this...
ReplyDeleteShell's sort is a good alternative as it doesn't degrade in performance like QuickSort if the result set is partially or fully sorted.
ReplyDeleteLars Fosdal Shell sort isn't stable.
ReplyDeleteMore stability to sort can be added with compare function I made something like this :
ReplyDeleteif a.x = b.x then
Result := CompareObjectPointerValues(a, b);
So as last resort I compared the Raw pointers of the objects, and they should always be different (if the implementation will not use duplicate objects references)
Simon Stuart I would be very grateful for this.
ReplyDeleteBeen using merge sort for a while, which seems to hold its own against timsort: http://gamasutra.com/view/news/172542/Indepth_Smoothsort_vs_Timsort.php#.URsHjBG9KSM
ReplyDeleteI'm not convinced being fast on already sorted arrays is such a great advantage, usually that's handled by flagging, on partially sorted arrays, timsort & merge sort are similar, and on random arrays timsort is worse. So not convinced the greater complexity (and potential for bugs) of timsort is really worth it.