02-07-2014 03:19 AM
Hello,
In statement step type, for the function Sort, the third argument specify whether to run a stable sort or not. Does anybody know what does it mean ?
Thanks
02-07-2014 10:09 AM - edited 02-07-2014 10:10 AM
A stable sort is one that preserves the relative ordering of equivalent elements. If you want to sort, but keep things with equal values in their same relative position, then use stable sort. If you don't care about that then don't use stable sort.
For an array of basic types, stable sort isn't necessary since you wouldn't notice any difference anyway, but for an array of objects it might be important.
Stable sorting algorithms can be signficantly slower than non-stable ones (you probably would only notice for very large arrays though).
Hope this helps,
-Doug