You are right, Parksie... It also depends on how many items you have to sort. That is why there is even the knut rule for the Shell Sort.
Anyway... I was here again searching for code for translating the Automaton program. (Yes, I have translated the class State so far and now I am translating the class Automaton) and I need to sort a vector of strings. And yes, I found "algorithm.h" but the example i found was using the size of the string to sort it. How can I sort it alphabetically?
I tried the following:
What am I doing wrong?PHP Code:#include <string>
#include <vector>
#include <algorithm>
// compare strings by length, descending order
bool compare(string const& x, string const& y) {
return x < y; //x.size() > y.size();
}
void SortVector(vector<string> V){
sort(V.begin(), V.end(), compare);
}
I don't want to program the Flagged-Bubble Sort... I already programmed MID, InStr and all those functions I would use on VB...




I don't want to program the Flagged-Bubble Sort... I already programmed MID, InStr and all those functions I would use on VB...
Rest in Peace, we will take care of the rest of it.
Reply With Quote