--- EventCalendar-094.py	2006-02-08 11:17:28.343750000 +0900
+++ EventCalendar-095.py	2006-02-08 11:11:25.296875000 +0900
              
@@ -565,7 +565,7 @@
     
     # sort events
     sorted_eventids = events.keys()
-    sorted_eventids.sort(cmp=lambda x,y: cmp(events[x]['startdate'], events[y]['startdate']))
+    sorted_eventids.sort(comp_list_events)
     
     for eid in sorted_eventids:
         if not events[eid]['clone']:
@@ -636,7 +636,7 @@
     
     # sort events
     sorted_eventids = events.keys()
-    sorted_eventids.sort(cmp=lambda x,y: cmp(events[x]['startdate'], events[y]['startdate']))
+    sorted_eventids.sort(comp_list_events)
     
     for eid in sorted_eventids:
         html_event_rows.append( listshow_event(events[eid], form_vals) )
@@ -728,6 +728,12 @@
         return 1
 
 
+# sort events in the list by start date of the event
+def comp_list_events(xid, yid):
+    events = Globs.events
+    
+    return cmp(events[xid]['startdate'], events[yid]['startdate'])
+
 # load events from wiki pages
 def loadEvents(datefrom='', dateto='', nocache=0):
     
@@ -1021,6 +1027,9 @@
         
     else:
         events = raw_events
+        
+        # store event list into global variables in order to sort them
+        Globs.events = events
 
     debug(u'Total %d of events are loaded finally.' % len(events))
     
