]> thyrsus.com Git - comparator.git/commitdiff
Better comparison so that sorting for merges works.
authorEric S. Raymond <esr@thyrsus.com>
Mon, 25 Aug 2003 20:29:44 +0000 (20:29 +0000)
committerEric S. Raymond <esr@thyrsus.com>
Mon, 25 Aug 2003 20:29:44 +0000 (20:29 +0000)
shredcompare.py

index b4263c6bd3e2fc3e717455b8f7281479a9448962..0e08cba4b2cf10e1431474fae71489a40faf797d 100755 (executable)
@@ -71,6 +71,9 @@ class Range:
             text += rfp.readline()
         rfp.close()
         return text
+    def __cmp__(self, other):
+        return cmp((self.file, self.start, self.end), 
+                   (other.file, other.start, other.end))
     def __str__(self):
         # 0-origin line numbers internally, 1-origin externally.
         return "%s:%d-%d" % (self.file, self.start+1, self.end)