3
vector<pair<string, int>> words;4
string arrangeWords(string text) {5
// convert to lowercase alphabet8
istringstream iss(text);11
// pos is the index of each word in text.15
words.push_back({word, pos});19
// sort by length and pos.20
sort(begin(words), end(words),21
[&](const pair<string, int> &p1, const pair<string, int> &p2) -> bool {22
if (size(p1.first) == size(p2.first)) return p1.second < p2.second;23
return size(p1.first) < size(p2.first);27
for (auto &x : words) ans += x.first + " ";30
// convert to uppercase alphabet