diff roundup/cgi/templating.py @ 4417:cc36be59ebd8

make sort more robust
author Richard Jones <richard@users.sourceforge.net>
date Fri, 10 Sep 2010 06:32:04 +0000
parents 66603a9051f9
children 261c9f913ff7
line wrap: on
line diff
--- a/roundup/cgi/templating.py	Fri Sep 10 06:31:30 2010 +0000
+++ b/roundup/cgi/templating.py	Fri Sep 10 06:32:04 2010 +0000
@@ -2314,13 +2314,19 @@
 
 
 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):

Roundup Issue Tracker: http://roundup-tracker.org/