Can I use this comparator for "C" unicode strings?

#include <iostream> #include <algorithm> class StrCmp { public: template <typename T> bool operator() (const T* p1, const T* p2) const { while (*p1 && *p2 && *p1 == *p2) ++p1, ++p2; return *p2 > *p1; } }; int main(int argc, char* argv[] ) { const char32_t* a[] { U"ЁЁЁ", U"АААААА", U"А", U"ЁЁЁ", U"ЁЁЁЁЁЁЁ", U"ААА" }; std::sort(a, a + 6, StrCmp() ); return 0; } 

if you can not why.

  • 2
    You can, if you do not care about collate issues. (i.e. it may turn out that some letter, for example, E is less than A). For collate - need weight table. - nick_n_a 2:41 pm
  • where to get the weight table? - Stanislav Petrov

0