title: Why isn't my string array being sorted correctly in c++?
body: <p>Here is my code and output. </p>
  
  <p>I essentially use selection sort as my algorithm. </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  void stringSort(string array[], int size)
  {
      string temp;
      int minIndex;
      for(int count=0;count&lt;size-1; count++)
      {
          minIndex=count;
          for(int index=count+1;index&lt;size;index++)
          {
              if(array[index]&lt;=array[minIndex])
              {
                  minIndex = index;
              }
              temp = array[count];
              array[count] = array[minIndex];
              array[minIndex] = temp;
  
          }
      }
  }
  int main()
  {
      string name[] =
      {  "Los Angeles ",  "Boise",  "Chicago",  "New Orleans",  "Calais",  "Boston",  "Duluth",  "Amarillo, TX "};
  
      int numberOfCities;
  
      numberOfCities = 8;
  
      int i;
      stringSort(name, numberOfCities);
  
      for (i =0; i&lt;numberOfCities; i++) {
          cout&lt;&lt; name[i]&lt;&lt;endl;
      }
      return 0;
  }
  </code></pre>
  
  <p>Output in my Xcode</p>
  
  <pre><code>Amarillo, TX 
  Boston
  Boise
  Calais
  Duluth
  Chicago
  Los Angeles 
  New Orleans
  </code></pre>
  
  <p>which is wrong because Chicago and Duluth should have been switched along with Boise + Boston. Everything else is fine. What gives? </p>