I looked everywhere and I could not find a concrete answer that suits my needs. I want use this type of format to sort a more complicated array than this example. It compiles, but when I run it I get the terminated by signal SIGSEV (address boundary error). 
A simple example of what I am trying to do:
string array[] = {zipper, bad, dog, apple, car};
string temparray[5];
int counter = 0;
for(int i = 0; i < 5; i++){
       for(int x = 0; x < 5; x++){
            if(array[i] > array[x]){
              counter++;
            }
        }
       temparray[counter] = array[i];
}
for(int y = 0; y < 5; y++){
       array[y] = temparray[y];   
}
What seems to be the problem?
 
     
    