natural_sort 0.1.0 → 0.2.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 +20 -4
- data/lib/natural_sort.rb +4 -0
- data/lib/natural_sort/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dfd714b89645e2d4fc0026d19e90f0281422d61
|
4
|
+
data.tar.gz: 3164c7c67926ff12f6cc1231cb38195000f14da1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ecfff960d299ddae782abd505017044ee7d3bcbcf3ca34bc4538b2412ef5632b84d72dfc99f98e9adaa906798cfb78254521e4813e7c6ab04e56eb916852eea4
|
7
|
+
data.tar.gz: e996ca5915e77c65a77e063bc7459663a0d9e69e8f52eb105d2413f8de350896deded52e8b73c43d41352984c9a568f65cb9e7f7be4452b054840a18094c1be9
|
data/README.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Natural Sort
|
2
2
|
|
3
|
+
[][travis]
|
4
|
+
[][gem]
|
5
|
+
[][codeclimate]
|
6
|
+
|
7
|
+
[travis]: https://travis-ci.org/rwz/natural_sort
|
8
|
+
[gem]: https://rubygems.org/gems/natural_sort
|
9
|
+
[codeclimate]: https://codeclimate.com/github/rwz/natural_sort
|
10
|
+
|
3
11
|
Natual sorting implementation in Ruby.
|
4
12
|
|
5
13
|
## Installation
|
@@ -21,10 +29,19 @@ Or install it yourself as:
|
|
21
29
|
## Usage
|
22
30
|
|
23
31
|
```ruby
|
24
|
-
|
32
|
+
list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
|
33
|
+
list.sort(&NaturalSort) # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
|
34
|
+
```
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
|
38
|
+
NaturalSort.sort(list) # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
|
39
|
+
```
|
25
40
|
|
41
|
+
```ruby
|
26
42
|
list = ["a10", "a", "a20", "a1b", "a1a", "a2", "a0", "a1"]
|
27
|
-
|
43
|
+
NaturalSort.sort! list # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
|
44
|
+
list # => ["a", "a0", "a1", "a1a", "a1b", "a2", "a10", "a20"]
|
28
45
|
```
|
29
46
|
|
30
47
|
```ruby
|
@@ -59,7 +76,7 @@ class MyClass
|
|
59
76
|
using NatualSort
|
60
77
|
|
61
78
|
list.natural_sort # => ["a", "a0", "a1", "a1a"...
|
62
|
-
ubuntu_releases.
|
79
|
+
ubuntu_releases.natural_sort_by(&:number) # => [ UbuntuRelease.new("8.10"...
|
63
80
|
end
|
64
81
|
```
|
65
82
|
|
@@ -73,4 +90,3 @@ https://github.com/rwz/natural_sort.
|
|
73
90
|
|
74
91
|
The gem is available as open source under the terms of the [MIT
|
75
92
|
License](http://opensource.org/licenses/MIT).
|
76
|
-
|
data/lib/natural_sort.rb
CHANGED
data/lib/natural_sort/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: natural_sort
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Pravosud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -44,7 +44,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
44
44
|
version: '0'
|
45
45
|
requirements: []
|
46
46
|
rubyforge_project:
|
47
|
-
rubygems_version: 2.
|
47
|
+
rubygems_version: 2.6.7
|
48
48
|
signing_key:
|
49
49
|
specification_version: 4
|
50
50
|
summary: Natural sorting support for Ruby
|