Ruby: sort UTF8 Strings alphabetical via Enumerable extension
Switch branches/tags
Pull request Compare This branch is 34 commits behind grosser:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
spec
.travis.yml
Gemfile
Gemfile.lock
Rakefile
Readme.md
VERSION
init.rb
sort_alphabetical.gemspec

Readme.md

Adds sort_alphabetical and sort_alphabetical_by to Enumberable(Array/Hash...), which sorts UTF8 Strings alphabetical. This sorting is done by placing variants on the same level as base character (A comes before Ä but ÄA comes before AB).

Setup

  • As Rails plugin: rails plugin install git://github.com/grosser/sort_alphabetical.git
  • As gem: sudo gem install sort_alphabetical

Usage

['b','á'].sort_alphabetical == ['á','b']
[['b',1],['á',2]].sort_alphabetical_by(&:first) == [['á',2],['b',1]]

SortAlphabetical.to_ascii('á') == 'a'

TODO

  • Sort non-ascii-convertables like ß(ss), œ(oe) , fi(fi), see Ligatures
  • Integrate natural sorting e.g. ['a11', 'a2'] => ['a2', 'a11'] like NaturalSort

Authors

Michael Grosser
michael@grosser.it
Hereby placed under public domain, do what you want, just do not hold me accountable...
Build Status