You are viewing a single comment's thread. Return to all comments →
using namespace std; bool compare(const string &a, const string &b) { if (a.length() != b.length()) return a.length() < b.length(); return a < b; }
vector bigSorting(vector unsorted) { sort(unsorted.begin(), unsorted.end(), compare); return unsorted; }
int main() { int n; cin >> n; vector unsorted(n);
for (int i = 0; i < n; ++i) { cin >> unsorted[i]; } vector<string> sorted = bigSorting(unsorted); for (const string &num : sorted) { cout << num << "\n"; } return 0;
}
Seems like cookies are disabled on this browser, please enable them to open this website
Big Sorting
You are viewing a single comment's thread. Return to all comments →
include
include
include
using namespace std; bool compare(const string &a, const string &b) { if (a.length() != b.length()) return a.length() < b.length(); return a < b; }
vector bigSorting(vector unsorted) { sort(unsorted.begin(), unsorted.end(), compare); return unsorted; }
int main() { int n; cin >> n; vector unsorted(n);
}