Do you have to use selection sort? You could use std::sort
instead if you define a custom comparison function:
bool compare_players(Player const& a, Player const& b) {
return (b.goals + b.assists) < (a.goals + a.assists);
}
Then throw your players into a vector
called players
and just
std::sort(players.begin(), players.end(), &compare_players);
This is less code and it's also more efficient (O(n log n)) than implementing a selection sort (O(n^2)).