Skip to content
Browse files

bugfix for zero or nil values

  • Loading branch information...
1 parent 09fd2f0 commit bc541caed155316506594e6330e6e95f62a161f5 @reiz reiz committed
Showing with 14 additions and 2 deletions.
  1. +1 −1 README.markdown
  2. +1 −1 lib/naturalsorter/version.rb
  3. +12 −0 lib/versioncmp.rb
View
2 README.markdown
@@ -49,7 +49,7 @@ Get newest.
You should add this line to your Gemfile
-`gem 'naturalsorter', '0.3.4'`
+`gem 'naturalsorter', '0.3.5'`
and run this command in your app root directory
View
2 lib/naturalsorter/version.rb
@@ -1,3 +1,3 @@
module Naturalsorter
- VERSION = "0.3.4"
+ VERSION = "0.3.5"
end
View
12 lib/versioncmp.rb
@@ -28,6 +28,18 @@ class Versioncmp
# 'Natural version order' comparison of two version strings
def self.compare(a, b)
+ if (!a.nil? || a.eql?("") ) && b.nil?
+ return 1
+ end
+
+ if (!b.nil? || b.eql?("")) && a.nil?
+ return -1
+ end
+
+ if a.nil? && b.nil?
+ return -1
+ end
+
offset1 = 0;
offset2 = 0;

0 comments on commit bc541ca

Please sign in to comment.
Something went wrong with that request. Please try again.