std::stable_sort
The function std::stable_sort is part of the C++ Standard Library and is used to sort elements in a range while maintaining the relative order of equivalent elements. This means that if two elements are considered equal based on the sorting criteria, their original order will be preserved in the sorted output.
std::stable_sort is typically implemented using a merge sort algorithm, which has a time complexity of O(n log n). It can be used with various data types, including arrays and vectors, and allows for custom sorting criteria through function pointers or lambda expressions.