[Solved] how to sort array of c++ strings alphabetically [closed]
It seems to me that your algorithm is wrong. Try making a few examples and run them by hand. Try this code instead: #include <algorithm> bool comp(string a, string b) { return a[0] < b[0]; } void sort(player *player_array, num_players) { string sorted[num_players]; for (int i = 0; i < num_players; ++i) sorted[i] = player_array[i].name; … Read more