stable_partition() rearranges elements in a container so that those satisfying a given condition come first, while preserving their original order.
- It’s called stable because it keeps the relative order of elements the same within each group.
- It divides elements in a container (like an array or vector) into two groups based on a given condition .
- The syntax of std::stable_sort is std::stable_sort(first, last, comp), where first and last specify the range of elements to be sorted, and comp is an optional comparison function that determines the sorting order.
- It is present in <algorithm> header file.