Sorting
See sorted…
Sample
data = ('b', 'c', 'a')
sorted(data)
>>> ['a', 'b', 'c']
key example 1:
from operator import attrgetter
return sorted(result, key=attrgetter('document.document_code'))
key example 2:
def key_issue_document_code(issue):
return issue.document.document_code
# elsewhere in the code...
return sorted(result, key=key_issue_document_code)