I have a task to sort vector in polish locale and what im trying to do is not working. Maybe this sorting is good but I don't understand it?
This is my approach
#include <algorithm>
#include <iostream>
#include <locale>
#include <string>
#include <vector>
using namespace std;
int main()
{
locale polish("pl_PL.UTF-8");
wcout.imbue(polish);
vector<wstring> v{
L"Słoń", L"Bąk", L"Bocian",
L"Ryś", L"Żyrafa", L"Lew",
L"Żuk", L"Bóbr", L"Anakonda",
L"Łoś", L"Bażant", L"Czapla"
};
cout << "Przed sortowaniem: ";
for (const auto& s : v)
wcout << s << " ";
cout << endl;
sort(v.begin(), v.end(), polish);
cout << "Po sortowaniu: ";
for (const auto& s : v)
wcout << s << " ";
cout << endl;
}
And what im getting is
Przed sortowaniem: Słoń Bąk Bocian Ryś Żyrafa Lew Żuk Bóbr Anakonda Łoś Bażant Czapla
Po sortowaniu: Anakonda Bażant Bocian Bóbr Bąk Czapla Lew Ryś Słoń Łoś Żuk Żyrafa
But for example Łoś should be after L and M. How can I get appropriate sort using only collate for polish location?