I don't really want to use struct is I do not have to, I need to sort latitudes and longitudes of a city that is picked from a cvs file from the user and sort the city's lat and lon from high to low or vice versa to the city the user pick.
but by sorting it high to slow, how to I do it and keep cities and countries along with their lat and long while sorting?
//input user for a name on city list
cout << "The worldcities.cvs contained infor on 120 cities." << endl;
cout << "Enter a city by name or number (1-120)" << endl;
constint MAX_ARRAY_SIZE = 121;
// file couldn't be opened
cout << "FAILED: file could not be opened" << endl << "Press enter to close.";
//inputs the file into 4 arrays for each catergories
for (int i=0;getline(file,(cities[i]),',');i++)
getline(file, countries[i], ',');
getline(file, latitudes[i], ',') ;
if(input == cities[i])
cout << "The city selected is" << " " << cities[i] << latitudes[i] <<endl;
cout << "I don't understand your input" << endl;
Easy way: use structs and let standard library do their work for you.
Hard way: implement your own sorting algorithm and each time you swap values in one array, swap corresponding values in other arrays.