#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;
}