api: sort using key function (#36515)
This commit is contained in:
parent
5d7bc70c0f
commit
be4101e5a7
|
@ -537,7 +537,7 @@ class ApiFormdefsDirectory(Directory):
|
|||
list_forms = self.get_list_forms(user, list_all_forms,
|
||||
backoffice_submission=backoffice_submission)
|
||||
|
||||
list_forms.sort(lambda x, y: cmp(x['category_position'], y['category_position']))
|
||||
list_forms.sort(key=lambda x: x['category_position'])
|
||||
for formdict in list_forms:
|
||||
del formdict['category_position']
|
||||
|
||||
|
@ -651,7 +651,7 @@ class ApiUserDirectory(Directory):
|
|||
for formdef in formdefs:
|
||||
user_forms.extend(formdef.data_class().get_with_indexed_value(
|
||||
'user_id', user.id))
|
||||
user_forms.sort(lambda x, y: cmp(x.receipt_time, y.receipt_time))
|
||||
user_forms.sort(key=lambda x: x.receipt_time)
|
||||
if get_request().form.get('sort') == 'desc':
|
||||
user_forms.reverse()
|
||||
return user_forms
|
||||
|
|
Loading…
Reference in New Issue