Newer
Older
#include "sort.h"
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_CHAR = 26;
string sortString(const string& input) {
int charCount[MAX_CHAR] = {0};
for (char i: input)
charCount[i - 'a']++;
string output;
for (int i = 0; i < MAX_CHAR; i++)
for (int j = 0; j < charCount[i]; j++)
output += (char) (i + 'a');
return output;
}