From: Eric S. Raymond Date: Mon, 25 Aug 2003 20:29:44 +0000 (+0000) Subject: Better comparison so that sorting for merges works. X-Git-Tag: 1.0~145 X-Git-Url: http://thyrsus.com/gitweb/?a=commitdiff_plain;h=f82c44283d64f975e83821865a97038f03198dae;p=comparator.git Better comparison so that sorting for merges works. --- diff --git a/shredcompare.py b/shredcompare.py index b4263c6..0e08cba 100755 --- a/shredcompare.py +++ b/shredcompare.py @@ -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)