Simplest method would be to just call the sort function on the array.
Code:
#include <string>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
int main()
{
string namesList[5] = {"alex","maria","betty","rolando","marlon"};
cout << "Before sort: ";
copy(namesList,namesList+5,ostream_iterator<string>(cout," "));
sort(namesList,namesList+5);
cout << "\nAfter sort : ";
copy(namesList,namesList+5,ostream_iterator<string>(cout," "));
return 0;
}
Should output:
Code:
Before sort: alex maria betty rolando marlon
After sort : alex betty maria marlon rolando