Skip to content

Commit

Permalink
improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
grosser committed Aug 5, 2017
1 parent c21bfb0 commit f8eea71
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,28 @@ 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).

Requirements
=====
- Ruby >= 1.9

Setup
=====
- As gem: ` sudo gem install sort_alphabetical `

```Bash
gem install sort_alphabetical
```

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

SortAlphabetical.normalize('á') == 'a'
```Ruby
['b','á'].sort_alphabetical == ['á','b']
[['b',1],['á',2]].sort_alphabetical_by(&:first) == [['á',2],['b',1]]

SortAlphabetical.normalize('á') == 'a'
```

Alternative
===========

Use [ICU](https://github.com/jarib/ffi-icu)

```Ruby
collator = ICU::Collation::Collator.new("nb")
array.sort! { |a,b| collator.compare(a, b) }
Expand Down

0 comments on commit f8eea71

Please sign in to comment.