String sort,
How to build the solution of this question;?
STRING SORT PROBLEM. .. ...
Hi, the straightforward solution is to build your own comparator.
Or a trick solution is to add āzā at the end of all the strings and simply sort.
Yes, please help me with building the comparator for this.
bool cmp(string &a, string &b) {
for (int i = 0; i < min(a.size(), b.size()); ++i) {
if (a[i] != b[i]) { return a[i] < b[i]; }
}
return (a.size() > b.size());
}
okay , thanks bhaiya . . . . .
1 Like