#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
vector<string> foo = {"Jonathan", "antenna", "jupiter", "Mee", "jOn"};
sort(foo.begin(), foo.end(), [](const auto& lhs, const auto& rhs){
const auto result = mismatch(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend(), [](const auto& lhs, const auto& rhs){return tolower(lhs) == tolower(rhs);});
return result.second != rhs.cend() && (result.first == lhs.cend() || tolower(*result.first) < tolower(*result.second));
});
for(auto& i : foo) {
cout << i << endl;
}
return 0;
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGNjdHlwZT4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJdmVjdG9yPHN0cmluZz4gZm9vID0geyJKb25hdGhhbiIsICJhbnRlbm5hIiwgImp1cGl0ZXIiLCAiTWVlIiwgImpPbiJ9OwoJCglzb3J0KGZvby5iZWdpbigpLCBmb28uZW5kKCksIFtdKGNvbnN0IGF1dG8mIGxocywgY29uc3QgYXV0byYgcmhzKXsKCQljb25zdCBhdXRvIHJlc3VsdCA9IG1pc21hdGNoKGxocy5jYmVnaW4oKSwgbGhzLmNlbmQoKSwgcmhzLmNiZWdpbigpLCByaHMuY2VuZCgpLCBbXShjb25zdCBhdXRvJiBsaHMsIGNvbnN0IGF1dG8mIHJocyl7cmV0dXJuIHRvbG93ZXIobGhzKSA9PSB0b2xvd2VyKHJocyk7fSk7CgkJCgkJcmV0dXJuIHJlc3VsdC5zZWNvbmQgIT0gcmhzLmNlbmQoKSAmJiAocmVzdWx0LmZpcnN0ID09IGxocy5jZW5kKCkgfHwgdG9sb3dlcigqcmVzdWx0LmZpcnN0KSA8IHRvbG93ZXIoKnJlc3VsdC5zZWNvbmQpKTsKCX0pOwoJCglmb3IoYXV0byYgaSA6IGZvbykgewoJCWNvdXQgPDwgaSA8PCBlbmRsOwoJfQoJcmV0dXJuIDA7Cn0=