sort_alphabetical 1.0.2 → 1.1.0
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.
- checksums.yaml +4 -4
- data/Readme.md +44 -0
- data/lib/sort_alphabetical.rb +7 -3
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 573aebe88b4243632689219e26378e1e0fa68dca
|
4
|
+
data.tar.gz: 296771d5b30c48b6f3fbae57150ac372a8c8ef62
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c41af982c562b0f80a946ab13a1320a8608b26b73c42e5b160b94eb8b7d40514fb99deddc7c384080910c32b2e1d840862069a8e3f10c4763747b3292d294ca9
|
7
|
+
data.tar.gz: 96f484964cf583ece41fb8b8df594bae45c90501035bc9634c8dc0e0ed300bd67d5d3148e870e607b8bc10f3e88a1bd1d8084514587f007c8230a32bfea42e0a
|
data/Readme.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
Adds `sort_alphabetical` and `sort_alphabetical_by` to Enumberable(Array/Hash...),
|
2
|
+
which sorts UTF8 Strings alphabetical.
|
3
|
+
This sorting is done by placing variants on the same level as base character (A comes before Ä but ÄA comes before AB).
|
4
|
+
|
5
|
+
Requirements
|
6
|
+
=====
|
7
|
+
- Ruby >= 1.9
|
8
|
+
|
9
|
+
Setup
|
10
|
+
=====
|
11
|
+
- As gem: ` sudo gem install sort_alphabetical `
|
12
|
+
|
13
|
+
Usage
|
14
|
+
=====
|
15
|
+
['b','á'].sort_alphabetical == ['á','b']
|
16
|
+
[['b',1],['á',2]].sort_alphabetical_by(&:first) == [['á',2],['b',1]]
|
17
|
+
|
18
|
+
SortAlphabetical.normalize('á') == 'a'
|
19
|
+
|
20
|
+
Alternative
|
21
|
+
===========
|
22
|
+
|
23
|
+
Use [ICU](https://github.com/jarib/ffi-icu)
|
24
|
+
```Ruby
|
25
|
+
collator = ICU::Collation::Collator.new("nb")
|
26
|
+
array.sort! { |a,b| collator.compare(a, b) }
|
27
|
+
```
|
28
|
+
|
29
|
+
TODO
|
30
|
+
====
|
31
|
+
- Sort non-ascii-convertables like ß(ss), œ(oe) , fi(fi), see [Ligatures](http://en.wikipedia.org/wiki/Typographical_ligature)
|
32
|
+
- Integrate natural sorting e.g. `['a11', 'a2'] => ['a2', 'a11']` like [NaturalSort](https://github.com/johnnyshields/naturalsort)
|
33
|
+
|
34
|
+
### [Contributors](https://github.com/grosser/sort_alphabetical/contributors)
|
35
|
+
=======
|
36
|
+
- original string_to_ascii: [Marc-Andre](http://marc-andre.ca/).
|
37
|
+
- [Maxime Menant](https://github.com/maxime-menant)
|
38
|
+
- [Victor D.](https://github.com/V1c70r)
|
39
|
+
- [Andrii Malyshko](https://github.com/nashbridges)
|
40
|
+
|
41
|
+
[Michael Grosser](http://grosser.it)<br/>
|
42
|
+
michael@grosser.it<br/>
|
43
|
+
License: MIT<br/>
|
44
|
+
[](https://travis-ci.org/grosser/sort_alphabetical)
|
data/lib/sort_alphabetical.rb
CHANGED
@@ -19,8 +19,12 @@ module SortAlphabetical
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def normalize(string)
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
result = String.new
|
23
|
+
UnicodeUtils.compatibility_decomposition(string).each_char do |c|
|
24
|
+
if UnicodeUtils.general_category(c) =~ /Letter|Separator|Punctuation|Number/
|
25
|
+
result << c
|
26
|
+
end
|
27
|
+
end
|
28
|
+
result
|
25
29
|
end
|
26
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sort_alphabetical
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Grosser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: unicode_utils
|
@@ -30,6 +30,7 @@ executables: []
|
|
30
30
|
extensions: []
|
31
31
|
extra_rdoc_files: []
|
32
32
|
files:
|
33
|
+
- Readme.md
|
33
34
|
- lib/sort_alphabetical.rb
|
34
35
|
- lib/sort_alphabetical/core_ext.rb
|
35
36
|
homepage: https://github.com/grosser/sort_alphabetical
|
@@ -44,7 +45,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
45
|
requirements:
|
45
46
|
- - ">="
|
46
47
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
+
version: 2.0.0
|
48
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
50
|
requirements:
|
50
51
|
- - ">="
|
@@ -52,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
53
|
version: '0'
|
53
54
|
requirements: []
|
54
55
|
rubyforge_project:
|
55
|
-
rubygems_version: 2.
|
56
|
+
rubygems_version: 2.4.5.1
|
56
57
|
signing_key:
|
57
58
|
specification_version: 4
|
58
59
|
summary: Sort UTF8 Strings alphabetical via Enumerable extension
|