Thanks. Committed along with a unit test to master as r10b5857.
Bug # sorting TypeError fix
Review Request #1168 - Created Oct. 8, 2009 and submitted
When entering multiple long numbers in the bug list of a review request, posting the request resulted in a TypeError. This patch should correct the issue.
Tested with a local Review Board installation. Numerical and lexicographical sorting still work correctly after applying the fix. Large bug # no longer trigger a TypeError.
I do not like the implementation: >>> bugs=['123456789123456789','89'] >>> bugs.sort(cmp=lambda x,y: int(x) - int(y)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: comparison function must return int, not long The proper way is to use python's function "cmp": >>> bugs=['123456789123456789','89'] >>> bugs.sort(lambda x,y: cmp(int(x),int(y))) >>> bugs ['89', '123456789123456789']
Very dodgy hack. This would not handle the case when the difference between x and y is a long number. The correct way is as follows: bugs.sort(lambda x,y: cmp(int(x),int(y)))