Updating branch refs/heads/master
to a297955686003f3d5fd1eb486519efd6635c7abe (commit)
from c28c0f2805343cccc26d9b955ae0a6af3699fc4c (commit)
commit a297955686003f3d5fd1eb486519efd6635c7abe
Author: Nick Schermer <[email protected]>
Date: Sun Oct 9 21:13:37 2011 +0200
Add natural sorting of version numbers.
lib/models/project.rb | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/lib/models/project.rb b/lib/models/project.rb
index 6ea3a6b..9464eae 100755
--- a/lib/models/project.rb
+++ b/lib/models/project.rb
@@ -55,10 +55,15 @@ module Moka
and other.branch == branch \
and other.version == version
end
-
+
def <=>(other)
return 0 unless other.is_a?(self.class)
- version <=> other.version
+ a = version.split('.')
+ b = other.version.split('.')
+ for n in (0..[a.length, b.length].min)
+ return a[n].to_i - b[n].to_i if not a[n].eql? b[n]
+ end
+ return version <=> other.version
end
def checksum(type)
_______________________________________________
Xfce4-commits mailing list
[email protected]
https://mail.xfce.org/mailman/listinfo/xfce4-commits