Do I need to switch to merge sort in my C / C ++ code and forget QuickSort?
Sorry to say, but the question sounds like an attempt at premature optimization.
Theoretically, the reason is that merge sort will be better parallelized and use memory / disk more economically and therefore faster than QuickSort RAM, but I don't know. What does practical experience indicate?
In practice, you should always first create a profile, and then identify areas of optimization based on the results.
You probably wonβt even have to change the sorting algorithm that you use, unless you do it over a sufficiently large data set for the results (or in a critical enough area of ββyour processing flow to matter).
Usually I use std :: sort, and if this is not enough (this has not happened for std::sort yet), I optimize the application flow and algorithms.
source share