Sort options by country-names
Closed this issue · 6 comments
Hi,
Onto now the options in country_select are sorted by their codes. Is it possbile to sort by the states' names? it is a better usability in my opinion.
thank you
This would be great! I vote for it.
It wasn't so hard, the easiest solution is to sort countries in the underlaying data file.
HOWTO:
Fork and download carmen source
cd to data/countries
gem install sort_alphabetical
fire up irb and for german:
require 'yaml'
require 'sort_alphabetical'
YAML::ENGINE.yamler='psych'
de = YAML::load(File.open('de.yml'))
de_sorted = de.sort_alphabetical
File.open('de_sort.yml','w') { |f| YAML.dump(de_sorted,out) }
Check de_sort.yml and replace de.yml with de_sort.yml.
RESULT (de, cs):
https://github.com/Pajk/carmen/commit/3272ce160393ab4cbb7ec8cd24f62ce243213395
Is pull request desired?
I agree that the names should be sorted by name and not code. But I think it might be better to do a sort in Ruby after the data is loaded. I'll add this to the backlog.
+1 and agree with Jim it should be done post loading not on the seed data.
+1
My fix lacco@8acbc62 uses sort_alphabetically gem on loading the data, is it worth making a pull request for this?
Lets leave this up to the user implementing the library, on how they want to sort it post-retrieval.