Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MP page does not sort correctly in Ukrainian #148

Closed
lisoffsky opened this issue Dec 6, 2015 · 10 comments
Closed

MP page does not sort correctly in Ukrainian #148

lisoffsky opened this issue Dec 6, 2015 · 10 comments
Assignees
Milestone

Comments

@lisoffsky
Copy link
Member

Edit by @henare: This is incorporates #147. Sorting on name or constituency on the MP page doesn't sort in the correct order for the Ukrainian language.


So we need help not only with sorting by oblast (#143) but also by name

When I try to sort by name on MPs page https://rada4you.org/people, what is default sorting, I see that sorting starts not by Ukrainian alphabet. Now page starts from letter "Є", but it should start from "А".

Can I somehow help with alphabet and oblasts, if needed?

@henare henare added the ready label Dec 7, 2015
@henare henare self-assigned this Dec 7, 2015
@henare henare added in progress and removed ready labels Dec 7, 2015
@henare henare closed this as completed in cceba4b Dec 7, 2015
@henare henare removed the in progress label Dec 7, 2015
@henare
Copy link
Member

henare commented Dec 7, 2015

@lisoffsky I think I've fixed this, can you please check?

@lisoffsky
Copy link
Member Author

I'm afraid not fully working.
In the bottom after MP Андрій Шипко sorting looks broken. Next after him MP Вікторія Сюмар should be way higher in a list. As other MPs.
Looks like sorting now works by their English names (and the same for oblasts) where Ukrainian letter "Ш" spelled like "sh" in English, e.g. That's why Ukrainian "T" surnames go after "Ш".

That's my guess.

@henare
Copy link
Member

henare commented Dec 7, 2015

Looks like sorting now works by their English names (and the same for oblasts) where Ukrainian letter "Ш" spelled like "sh" in English, e.g. That's why Ukrainian "T" surnames go after "Ш".

That's my guess.

Yes, you're right! cceba4b

Reopening this issue to investigate if we can sort in Ukrainian.

@henare henare reopened this Dec 7, 2015
@henare henare changed the title MPs names sorting issue MP page does not sort correctly in Ukrainian. Dec 8, 2015
@henare henare changed the title MP page does not sort correctly in Ukrainian. MP page does not sort correctly in Ukrainian Dec 8, 2015
@henare henare added the bug label Dec 8, 2015
@henare henare added this to the MVP milestone Dec 8, 2015
@henare
Copy link
Member

henare commented Dec 8, 2015

We know that sorting in transliterated Ukrainian doesn't sort correctly in the Ukrainian alphabet.

I next looked around for ways to get Ruby to sort correctly in Ukrainian. The TwitterCLDR library can do that but it doesn't do #sort_by. Writing something to do this ourselves seems like complex yak shaving.

So that made me look at doing this sorting in the DB again because I know databases should be able to sort this correctly. The reason why we're doing sorting in Ruby is because we've got a pretty complex sort hierarchy and all the attributes we sort on aren't accessible in the DB in a simple way (i.e. rebellions & attendance for the Person).

I think the most sensible thing to do is to sort in the DB for the queries we can and leave the ones we can't as-is. This will mean that there's not great secondary sorting on rebellions and attendance in Ukrainian because it will use the dumb name sorting for those two only.

It also means we lose our 4th level tertiary sorting -m.entered_house.to_time.to_i on the queries we start using the DB for. It seems like there's such a remote chance of this ever being actually used in sorting that it's fine we lose this.

@henare henare closed this as completed in e3b0dd0 Dec 8, 2015
henare added a commit that referenced this issue Dec 8, 2015
This allows us to correctly sort by name (#148) or electorate (#147)
but it still means that secondary sorting on rebellions or attendance
doesn't work.

This seems like the best trade off we have for the moment. See
discussion/comments at:

#148 (comment)
@henare
Copy link
Member

henare commented Dec 8, 2015

@lisoffsky I've made this change so sorting by name and oblast should be working, can you please check again?

I've also opened #159 to track the remaining smaller issue that we're not planning to resolve for this part of the project.

@lisoffsky
Copy link
Member Author

Yes, it now sorts very well! Thank you, Henare!

@beastie87
Copy link
Member

Maybe use need gem 'chars' for sort_by
require 'chars'
a= ['Борис','Андрей','Яна', 'Мария']
p a.sort_by {|word| word.chars}
#results => ["Андрей", "Борис", "Мария", "Яна"]

@beastie87 beastie87 reopened this Dec 8, 2015
@lisoffsky
Copy link
Member Author

@beastie87 beware, your example is in Russian language

@beastie87
Copy link
Member

Sorry Ukrainian is also Cyrillic
require 'chars'
a= ['Андрій','Марія', 'Василь', 'Геннадій']
p a.sort_by {|word| word.chars}
#results=>["Андрій", "Василь", "Геннадій", "Марія"]
But Ukrainian letters "і" and 'є' is the problem
require 'chars'
a= ['Андрій','Марія', 'Василь', 'Геннадій','Іван', 'Євген']
p a.sort_by {|word| word.chars}
#results=>["Євген", "Іван", "Андрій", "Василь", "Геннадій", "Марія"]

@henare henare removed the in progress label Dec 8, 2015
@henare
Copy link
Member

henare commented Dec 9, 2015

Yes, it now sorts very well! Thank you, Henare!

@lisoffsky woohoo!

Maybe use need gem 'chars' for sort_by

@beastie87 that's really interesting. I wonder if we could expand chars to support Ukrainian?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants