sort-by-alphabet 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/enumerable.rb +10 -2
- metadata +1 -1
data/lib/enumerable.rb
CHANGED
@@ -1,11 +1,19 @@
|
|
1
1
|
module Enumerable
|
2
2
|
|
3
3
|
def sort_by_alphabet(alphabet)
|
4
|
-
|
4
|
+
if block_given?
|
5
|
+
sort{|a, b| yield(a).to_s.compare_by_alphabet_sensitive(yield(b).to_s, alphabet)}
|
6
|
+
else
|
7
|
+
sort{|a, b| a.to_s.compare_by_alphabet_sensitive(b.to_s, alphabet)}
|
8
|
+
end
|
5
9
|
end
|
6
10
|
|
7
11
|
def isort_by_alphabet(alphabet)
|
8
|
-
|
12
|
+
if block_given?
|
13
|
+
sort{|a, b| yield(a).to_s.compare_by_alphabet_insensitive(yield(b).to_s, alphabet)}
|
14
|
+
else
|
15
|
+
sort{|a, b| a.to_s.compare_by_alphabet_insensitive(b.to_s, alphabet)}
|
16
|
+
end
|
9
17
|
end
|
10
18
|
|
11
19
|
end
|