# Each key in this dictionary corresponds to our application's url, including trailing slash. # The value of each entry is a list of URLs of our models, in the order we would like them to be displayed. modelOrder = {} modelOrder['agentAccess/'] = ['agentAccess/post/', 'agentAccess/post_category/', 'agentAccess/page/', 'agentAccess/page_category/', 'agentAccess/fileupload/'] # Check if we have a corresponding ordering list, if not, sort by name. for app in app_list: if modelOrder.get(app['app_url'], None): app['models'].sort(lambda x, y: cmp(modelOrder[app['app_url']].index(x['admin_url']), modelOrder[app['app_url']].index(y['admin_url']))) else: app['models'].sort(lambda x, y: cmp(x['name'], y['name']))