From 38fb28e928b47aa139dc975636d0ef7a17ddafbb Mon Sep 17 00:00:00 2001 From: richard Date: Fri, 10 Sep 2010 06:32:04 +0000 Subject: [PATCH] make sort more robust git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4523 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/cgi/templating.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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): -- 2.30.2