Check out example codes for "sort a string alphabetically c++". It will help you in understanding the concepts better.

Code Example 1

// C++ program to sort a string of characters 
#include<bits/stdc++.h> 
using namespace std; 
  
// function to print string in sorted order 
void sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
   cout << str; 
} 
  
// Driver program to test above function 
int main() 
{ 
    string s = "geeksforgeeks";  
    sortString(s);  
    return 0; 
}

Learn ReactJs, React Native from akashmittal.com