sort-by-alphabet 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.textile +13 -3
- data/lib/alphabets.rb +1 -1
- 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
|
33
|
+
bc.. class Something
|
34
34
|
comparable_by_alphabet(CzechAlphabet)
|
35
35
|
end
|
36
36
|
|
37
|
-
|
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
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.
|
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-
|
12
|
+
date: 2010-01-23 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|