naturally 1.0.1 → 1.0.2

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.
@@ -2,19 +2,20 @@ require "naturally/version"
2
2
 
3
3
  module Naturally
4
4
 
5
- # @return [Array] of strings sorted as if they
6
- # were numbers.
5
+ # Perform a natural sort.
6
+ # @param [Array<String>] a list of numbers to sort.
7
+ # @return [Array<String>] the numbers sorted naturally.
7
8
  def self.sort(an_array)
8
9
  return an_array.sort_by{ |x| normalize(x) }
9
- end
10
-
11
-
12
- private
10
+ end
13
11
 
14
12
  def self.normalize(version)
15
13
  version.to_s.scan(%r/[0-9a-zA-Z]+/o).map{|i| NumberElement.new(i)}
16
14
  end
17
15
 
16
+
17
+ private
18
+
18
19
  class NumberElement
19
20
  include Comparable
20
21
  attr_accessor :val
@@ -1,3 +1,3 @@
1
1
  module Naturally
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naturally
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: