diff --git a/openslides/assignment/models.py b/openslides/assignment/models.py index 85491b9a2..e4f6fa570 100644 --- a/openslides/assignment/models.py +++ b/openslides/assignment/models.py @@ -13,6 +13,7 @@ from django.core.urlresolvers import reverse from django.db import models from django.utils.translation import ugettext as _, ugettext_lazy, ugettext_noop +from django.utils.datastructures import SortedDict from openslides.utils.person import PersonField from openslides.config.api import config @@ -173,7 +174,7 @@ class Assignment(models.Model, SlideMixin): returns a table represented as a list with all candidates from all related polls and their vote results. """ - vote_results_dict = {} + vote_results_dict = SortedDict() # All polls related to this assigment polls = self.poll_set.all() if only_published: @@ -183,6 +184,8 @@ class Assignment(models.Model, SlideMixin): for poll in polls: options += poll.get_options() + options.sort(key=lambda option: option.candidate.sort_name) + for option in options: candidate = option.candidate if candidate in vote_results_dict: