6void countSort(
string arr) {
10 for (
int i = 0; i < 256; i++) count[i] = 0;
12 for (i = 0; arr[i]; ++i) ++count[arr[i]];
14 for (i = 1; i < 256; ++i) count[i] += count[i - 1];
16 for (i = 0; arr[i]; ++i) {
17 output[count[arr[i]] - 1] = arr[i];
21 for (i = 0; arr[i]; ++i) arr[i] = output[i];
23 cout <<
"Sorted character array is " << arr;