
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
stable_sort() in C++ STL
The stable_sort method of STL first sorts the components with name as the key in ascending order and afterward the components are arranged with their segment as the key. Moreover, The stable_sort() calculation is viewed as steady in light of the fact that the overall request of comparable components is kept up. Here is the source code of the C++ program which exhibits the stable_sort() calculation demonstrated as follows;
Example
#include <bits/stdc++.h> using namespace std; int main(){ int arr[] = { 11, 15, 18, 19, 16, 17, 13, 20, 14, 12, 10 }; int n = sizeof(arr) / sizeof(arr[0]); stable_sort(arr, arr + n); cout << "Array after sorting is ="; for (int i = 0; i < n; ++i) cout << arr[i] << " "; return 0; }
Output
This C++ program yields the following array to be sorted in ascending order as follows;
Array after sorting is= 10 11 12 13 14 15 16 17 18 19 20
- Related Articles
- Insertion sort using C++ STL
- Sort in C++ Standard Template Library (STL)
- Stable Personality Trait
- How to sort an Array using STL in C++?
- How to sort a Vector in descending order using STL in C++?
- Are atoms of all elements stable?
- Signals and Systems: Stable and Unstable System
- Difference Between Myocardial Infarction and Stable Angina
- Does the Equity Beta remain stable over time?
- Is Flutter a stable platform to develop cross platform application?
- Containers in C++ STL
- count_if() in C++ STL
- Library in C++ STL?
- deque_resize( ) in C++ in STL
- deque_rbegin( ) in C++ in STL

Advertisements