I have a vector<string>
container but the strings are all numbers
EDIT: I tried this:
so now the logic seems to be borked
cleaned this up but experimenting with various attempts to cast std::string to an int is tough lamba was useless and I have run out of ideas for casting std::string without some bug surfacing
template<typename Iterator>void bubbleSort(Iterator first, Iterator last){
Iterator i, j;
for (i = first; i != last; i++)
for (j = first; j < i; j++)
if (*i < *j)
std::iter_swap(i, j); // or std::swap(*i, *j);
}
My code to read the source data is
void loadgames(void) { // read the game app id's
ifstream inFile;
ofstream outFile;
string s;
inFile.open("game-list.txt");
if (inFile.is_open()) {
while (std::getline(inFile, s)) {
if(s.length() > 0)
gamelist.push_back(s);
};
inFile.close();
}
// bubbleSort(gamelist.begin(),gamelist.end());
outFile.open("game-list.txt");
if (outFile.is_open()) {
for (i = gamelist.begin(); i != gamelist.end(); i++) {
outFile << *i << endl;
}
}
outFile.close();
}
The call to is the problem of sorting my vector
bubbleSort(gamelist.begin(),gamelist.end());