#pragma once #include #include #include #include #include template inline void AlphabeticalSort(typename T start, typename T end, std::function::value_type &)> get_string) { std::sort(start, end, [&](const auto &a, const auto &b) -> bool { const std::string &s1 = get_string(a); const std::string &s2 = get_string(b); if (s1.empty() || s2.empty()) return s1 < s2; bool ac[] = { !isalnum(s1[0]), !isalnum(s2[0]), !!isdigit(s1[0]), !!isdigit(s2[0]), !!isalpha(s1[0]), !!isalpha(s2[0]), }; if ((ac[0] && ac[1]) || (ac[2] && ac[3]) || (ac[4] && ac[5])) return s1 < s2; return ac[0] || ac[5]; }); }