Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding doc

  • Loading branch information...
commit 2fe588d9479f34762b066005c103974f3e920d89 1 parent 7e48146
reiz authored
Showing with 26 additions and 2 deletions.
  1. +24 −0 lib/naturalsorter.rb
  2. +2 −2 naturalsorter.gemspec
View
24 lib/naturalsorter.rb
@@ -1,10 +1,33 @@
require "naturalsorter/version"
require "natcmp"
+# naturalsorter.rb
+#
+# Natural order sorting for an array of strings or more advanced objects
+#
+# This implementation is Copyright (C) 2012 by Robert Reiz
+#
+# This software is provided 'as-is', without any express or implied
+# warranty. In no event will the authors be held liable for any damages
+# arising from the use of this software.
+#
+# Permission is granted to anyone to use this software for any purpose,
+# including commercial applications, and to alter it and redistribute it
+# freely, subject to the following restrictions:
+#
+# 1. The origin of this software must not be misrepresented; you must not
+# claim that you wrote the original software. If you use this software
+# in a product, an acknowledgment in the product documentation would be
+# appreciated but is not required.
+# 2. Altered source versions must be plainly marked as such, and must not be
+# misrepresented as being the original software.
+# 3. This notice may not be removed or altered from any source distribution.
+
module Naturalsorter
class Sorter
+ # 'Natural order' sort for an simple string array
def self.sort(array, caseinsesitive)
if (array.nil? || array.empty?)
return nil
@@ -12,6 +35,7 @@ def self.sort(array, caseinsesitive)
array.sort { |a,b| Natcmp.natcmp(a,b,caseinsesitive) }
end
+ # 'Natural order' sort for an array of objects.
def self.sort_by_method(array, method, caseinsesitive)
if (array.nil? || array.empty?)
return nil
View
4 naturalsorter.gemspec
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.version = Naturalsorter::VERSION
s.authors = ["reiz"]
s.email = ["robert.reiz@gmx.com"]
- s.homepage = "http://robert-reiz.com"
+ s.homepage = "https://github.com/reiz/naturalsorter"
s.summary = %q{Sorting arrays in natural order}
s.description = %q{This GEM is sorting Arrays in a natural order. a2 < a10}
@@ -22,4 +22,4 @@ Gem::Specification.new do |s|
# s.add_development_dependency "rspec"
# s.add_runtime_dependency "rest-client"
s.add_development_dependency "rspec", "~> 2.6"
-end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.