From: richard Date: Fri, 10 Sep 2010 06:32:04 +0000 (+0000) Subject: make sort more robust X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=38fb28e928b47aa139dc975636d0ef7a17ddafbb;p=roundup.git make sort more robust git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4523 57a73879-2fb5-44c3-a270-3262357dd7e2 --- diff --git a/roundup/cgi/templating.py b/roundup/cgi/templating.py index a08dbcd..2d8ea77 100644 --- a/roundup/cgi/templating.py +++ b/roundup/cgi/templating.py @@ -2314,13 +2314,19 @@ def register_propclass(prop, cls): def make_sort_function(db, classname, sort_on=None): - """Make a sort function for a given class + """Make a sort function for a given class. + + The list being sorted may contain mixed ids and labels. """ linkcl = db.getclass(classname) if sort_on is None: sort_on = linkcl.orderprop() def sortfunc(a, b): - return cmp(linkcl.get(a, sort_on), linkcl.get(b, sort_on)) + if num_re.match(a): + a = linkcl.get(a, sort_on) + if num_re.match(b): + b = linkcl.get(b, sort_on) + return cmp(a, b) return sortfunc def handleListCGIValue(value):