Closed Kampfkarren closed 7 years ago
The advantage mergesort has over quicksort is that mergesort is stable (i.e. preserves the order of equal-valued elements)
What's the advantage of that?
Things like UIListLayout call it because it's faster to keep the whole sort in Lua than it is to continually call a sort order callback. In general, it's fairly slow for C++ to call a Lua function.
It's merge sort because you need the order to stay the same every time, or elements would jump around on screen.
Hm, alright. Closed.
https://github.com/Roblox/Core-Scripts/blob/master/CoreScriptsRoot/MergeSort.lua
I noticed this file while clicking around. What's the point of this? Why not just use table.sort? Why use MergeSort of all sorting algorithms? table.sort already uses QuickSort.