Skip to content

Commit 8c2680c

Browse files
author
Richard Jones
committed
make sort more robust
1 parent 1733472 commit 8c2680c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

roundup/cgi/templating.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2314,13 +2314,19 @@ def register_propclass(prop, cls):
23142314

23152315

23162316
def make_sort_function(db, classname, sort_on=None):
2317-
"""Make a sort function for a given class
2317+
"""Make a sort function for a given class.
2318+
2319+
The list being sorted may contain mixed ids and labels.
23182320
"""
23192321
linkcl = db.getclass(classname)
23202322
if sort_on is None:
23212323
sort_on = linkcl.orderprop()
23222324
def sortfunc(a, b):
2323-
return cmp(linkcl.get(a, sort_on), linkcl.get(b, sort_on))
2325+
if num_re.match(a):
2326+
a = linkcl.get(a, sort_on)
2327+
if num_re.match(b):
2328+
b = linkcl.get(b, sort_on)
2329+
return cmp(a, b)
23242330
return sortfunc
23252331

23262332
def handleListCGIValue(value):

0 commit comments

Comments
 (0)