sort-by-alphabet 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.textile +13 -3
  2. data/lib/alphabets.rb +1 -1
  3. metadata +2 -2
data/README.textile CHANGED
@@ -28,13 +28,23 @@ bc. %w{nazdar ahoj čau}.sort_by_alphabet(CzechAlphabet) # => %w{ahoj čau nazda
28
28
 
29
29
  bc. Something.all.sort_by_alphabet(CzechAlphabet) {|o| o.title}
30
30
 
31
- You can also make a class alphabetically comparable:
31
+ You can also make a class alphabetically comparable, enabling sorting:
32
32
 
33
- bc. class Something
33
+ bc.. class Something
34
34
  comparable_by_alphabet(CzechAlphabet)
35
35
  end
36
36
 
37
- or use a block, e.g. for case insensitivity:
37
+ a = Something.new
38
+ b = Something.new
39
+ c = Something.new
40
+
41
+ # the following comparisons will be using to_s and lexical order given by Czech alphabet
42
+
43
+ a <=> b
44
+
45
+ [a, b, c].sort
46
+
47
+ p. or use a block, e.g. for case insensitivity:
38
48
 
39
49
  bc. class SomethingElse
40
50
  comparable_by_alphabet(CzechAlphabet) {|obj| obj.mb_chars.downcase}
data/lib/alphabets.rb CHANGED
@@ -6,7 +6,7 @@ class Alphabet
6
6
  if i && j
7
7
  i <=> j
8
8
  else
9
- x <=> y
9
+ x.mb_chars.normalize(:d) <=> y.mb_chars.normalize(:d)
10
10
  end
11
11
  end
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sort-by-alphabet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frantisek Havluj
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-22 00:00:00 +01:00
12
+ date: 2010-01-23 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15