Use std::stable_sort instead of mergesort.

* stable_sort is part of the C++ standard, and should work just as well.