#define SIZE 7
#include <iostream>

using namespace std;

void show(string ar[], int len, const char *caption = "") {
	cout << caption << " - ";
	for (int i=0; i<len; ++i) {
		cout << ar[i] << ", ";
	}
	cout << endl;
}

void verydumbsort(string ar[], int len) {
	string arbuf[26][SIZE];
	int arb_i[26] = { 0 };
	
	for (int j=0; j<len; ++j) {
		char initial = ar[j][0];
		if (initial >= 'a') {
			initial -= ('a' - 'A');
		}
		initial -= 65;
		// cout << ar[j] << '\t' << ((int) initial) << endl;
		arbuf[initial][arb_i[initial]] = ar[j];
		++arb_i[initial];
	}
	
	/*
	for (int k=0; k<26; ++k) {
		cout << "buffer " << ((char) (k+65));
		show(arbuf[k], SIZE);
	}
	*/
	
	int ar_index = 0;
	for (int m=0; m<26; ++m) {
		for (int n=0; n<arb_i[m]; ++n) {
			if (arbuf[m][n].length() > 0) {
				ar[ar_index] = arbuf[m][n];
				++ar_index;
			}
		}
	}
}

int main() {
	string word[SIZE];
	word[0]="Hello";
	word[1]="World";
	word[2]="Bye";
	word[3]="ggyy";
	word[4]="bison";
	word[5]="hotel";
	word[6]="benny";

	show(word, SIZE, "before");
	
	verydumbsort(word, SIZE);
	
	show(word, SIZE, "after");
	
	return 0;
}