sort a string array alphabetically

hello, i wish to sort a string array alphabetically and im not sure if i am doing it right. for example:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

string a[5]; //initial array
string b[5]; //sorted array
int index = 0; //index of b array
	
for (int i = 0; i < 5; i++){
	for (int j = 0; j < 5; j++){
		int c = 0;
		c = a[i].compare(a[i]);
		if (c > 0){ 
			b[index] = a[j];
			index++; 
		}		
	}




any idea why its not working?
You could just use:
std::sort(a, a+5); // a is now sorted

But for one, on line 9, you are comparing a[i] to itself; that will always return equal.
wow it worked. that was so simpleee !!! thank you very much!
Topic archived. No new replies allowed.