Use python for sorting instead of django

- This allows sorting in the UI via properties that aren't necessarily
  part of the model

Ticket: #6924