##// END OF EJS Templates
Make the versions with the same date sorted by name (#864)....
Jean-Philippe Lang -
r1281:ecc742f3ce33
parent child
Show More
@@ -89,11 +89,11 class Version < ActiveRecord::Base
89
89
90 def to_s; name end
90 def to_s; name end
91
91
92 # Versions are sorted by effective_date
92 # Versions are sorted by effective_date and name
93 # Those with no effective_date are at the end, sorted by name
93 # Those with no effective_date are at the end, sorted by name
94 def <=>(version)
94 def <=>(version)
95 if self.effective_date
95 if self.effective_date
96 version.effective_date ? (self.effective_date <=> version.effective_date) : -1
96 version.effective_date ? (self.effective_date == version.effective_date ? self.name <=> version.name : self.effective_date <=> version.effective_date) : -1
97 else
97 else
98 version.effective_date ? 1 : (self.name <=> version.name)
98 version.effective_date ? 1 : (self.name <=> version.name)
99 end
99 end
General Comments 0
You need to be logged in to leave comments. Login now