prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Organisations listed in filter on project overview unsorted
  The list of organisations listed in filter on the project overview page is unsorted and determined by the order of creating the organisations. I think it would be best to sort them alphabetically.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `apps/projects/views.py`
  Content:
  ```
  1 from datetime import datetime
  2 import django_filters
  3 from django.apps import apps
  4 from django.conf import settings
  5 from django.utils.translation import ugettext_lazy as _
  6 
  7 from adhocracy4.filters import views as filter_views
  8 from adhocracy4.filters.filters import DefaultsFilterSet
  9 from adhocracy4.projects import models as project_models
  10 
  11 from apps.contrib.widgets import DropdownLinkWidget
  12 from apps.dashboard import blueprints
  13 
  14 
  15 class OrderingWidget(DropdownLinkWidget):
  16     label = _('Ordering')
  17     right = True
  18 
  19 
  20 class OrganisationWidget(DropdownLinkWidget):
  21     label = _('Organisation')
  22 
  23 
  24 class ArchivedWidget(DropdownLinkWidget):
  25     label = _('Archived')
  26 
  27     def __init__(self, attrs=None):
  28         choices = (
  29             ('', _('All')),
  30             ('false', _('No')),
  31             ('true', _('Yes')),
  32         )
  33         super().__init__(attrs, choices)
  34 
  35 
  36 class YearWidget(DropdownLinkWidget):
  37     label = _('Year')
  38 
  39     def __init__(self, attrs=None):
  40         choices = (('', _('Any')),)
  41         now = datetime.now().year
  42         try:
  43             first_year = project_models.Project.objects.earliest('created').\
  44                 created.year
  45         except project_models.Project.DoesNotExist:
  46             first_year = now
  47         for year in range(now, first_year - 1, -1):
  48             choices += (year, year),
  49         super().__init__(attrs, choices)
  50 
  51 
  52 class TypeWidget(DropdownLinkWidget):
  53     label = _('Project Type')
  54 
  55     def __init__(self, attrs=None):
  56         choices = (('', _('Any')),)
  57         for blueprint_key, blueprint in blueprints.blueprints:
  58             choices += (blueprint_key, blueprint.title),
  59         super().__init__(attrs, choices)
  60 
  61 
  62 class ProjectFilterSet(DefaultsFilterSet):
  63 
  64     defaults = {
  65         'is_archived': 'false'
  66     }
  67 
  68     ordering = django_filters.OrderingFilter(
  69         choices=(
  70             ('-created', _('Most recent')),
  71         ),
  72         empty_label=None,
  73         widget=OrderingWidget,
  74     )
  75 
  76     organisation = django_filters.ModelChoiceFilter(
  77         queryset=apps.get_model(settings.A4_ORGANISATIONS_MODEL).objects.all(),
  78         widget=OrganisationWidget,
  79     )
  80 
  81     is_archived = django_filters.BooleanFilter(
  82         widget=ArchivedWidget
  83     )
  84 
  85     created = django_filters.NumberFilter(
  86         name='created',
  87         lookup_expr='year',
  88         widget=YearWidget,
  89     )
  90 
  91     typ = django_filters.CharFilter(
  92         widget=TypeWidget,
  93     )
  94 
  95     class Meta:
  96         model = project_models.Project
  97         fields = ['organisation', 'is_archived', 'created', 'typ']
  98 
  99 
  100 class ProjectListView(filter_views.FilteredListView):
  101     model = project_models.Project
  102     paginate_by = 16
  103     filter_set = ProjectFilterSet
  104 
  105     def get_queryset(self):
  106         return super().get_queryset().filter(is_draft=False)
  107
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/apps/projects/views.py b/apps/projects/views.py
  --- a/apps/projects/views.py
  +++ b/apps/projects/views.py
  @@ -54,7 +54,8 @@
   
       def __init__(self, attrs=None):
           choices = (('', _('Any')),)
  -        for blueprint_key, blueprint in blueprints.blueprints:
  +        sorted_blueprints = sorted(blueprints.blueprints, key=lambda a: a[1])
  +        for blueprint_key, blueprint in sorted_blueprints:
               choices += (blueprint_key, blueprint.title),
           super().__init__(attrs, choices)
   
  @@ -74,7 +75,8 @@
       )
   
       organisation = django_filters.ModelChoiceFilter(
  -        queryset=apps.get_model(settings.A4_ORGANISATIONS_MODEL).objects.all(),
  +        queryset=apps.get_model(settings.A4_ORGANISATIONS_MODEL).objects
  +                     .order_by('name'),
           widget=OrganisationWidget,
       )
  
verification_info: {"golden_diff": "diff --git a/apps/projects/views.py b/apps/projects/views.py\n--- a/apps/projects/views.py\n+++ b/apps/projects/views.py\n@@ -54,7 +54,8 @@\n \n     def __init__(self, attrs=None):\n         choices = (('', _('Any')),)\n-        for blueprint_key, blueprint in blueprints.blueprints:\n+        sorted_blueprints = sorted(blueprints.blueprints, key=lambda a: a[1])\n+        for blueprint_key, blueprint in sorted_blueprints:\n             choices += (blueprint_key, blueprint.title),\n         super().__init__(attrs, choices)\n \n@@ -74,7 +75,8 @@\n     )\n \n     organisation = django_filters.ModelChoiceFilter(\n-        queryset=apps.get_model(settings.A4_ORGANISATIONS_MODEL).objects.all(),\n+        queryset=apps.get_model(settings.A4_ORGANISATIONS_MODEL).objects\n+                     .order_by('name'),\n         widget=OrganisationWidget,\n     )\n", "issue": "Organisations listed in filter on project overview unsorted\nThe list of organisations listed in filter on the project overview page is unsorted and determined by the order of creating the organisations. I think it would be best to sort them alphabetically.\n", "before_files": [{"content": "from datetime import datetime\nimport django_filters\nfrom django.apps import apps\nfrom django.conf import settings\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom adhocracy4.filters import views as filter_views\nfrom adhocracy4.filters.filters import DefaultsFilterSet\nfrom adhocracy4.projects import models as project_models\n\nfrom apps.contrib.widgets import DropdownLinkWidget\nfrom apps.dashboard import blueprints\n\n\nclass OrderingWidget(DropdownLinkWidget):\n    label = _('Ordering')\n    right = True\n\n\nclass OrganisationWidget(DropdownLinkWidget):\n    label = _('Organisation')\n\n\nclass ArchivedWidget(DropdownLinkWidget):\n    label = _('Archived')\n\n    def __init__(self, attrs=None):\n        choices = (\n            ('', _('All')),\n            ('false', _('No')),\n            ('true', _('Yes')),\n        )\n        super().__init__(attrs, choices)\n\n\nclass YearWidget(DropdownLinkWidget):\n    label = _('Year')\n\n    def __init__(self, attrs=None):\n        choices = (('', _('Any')),)\n        now = datetime.now().year\n        try:\n            first_year = project_models.Project.objects.earliest('created').\\\n                created.year\n        except project_models.Project.DoesNotExist:\n            first_year = now\n        for year in range(now, first_year - 1, -1):\n            choices += (year, year),\n        super().__init__(attrs, choices)\n\n\nclass TypeWidget(DropdownLinkWidget):\n    label = _('Project Type')\n\n    def __init__(self, attrs=None):\n        choices = (('', _('Any')),)\n        for blueprint_key, blueprint in blueprints.blueprints:\n            choices += (blueprint_key, blueprint.title),\n        super().__init__(attrs, choices)\n\n\nclass ProjectFilterSet(DefaultsFilterSet):\n\n    defaults = {\n        'is_archived': 'false'\n    }\n\n    ordering = django_filters.OrderingFilter(\n        choices=(\n            ('-created', _('Most recent')),\n        ),\n        empty_label=None,\n        widget=OrderingWidget,\n    )\n\n    organisation = django_filters.ModelChoiceFilter(\n        queryset=apps.get_model(settings.A4_ORGANISATIONS_MODEL).objects.all(),\n        widget=OrganisationWidget,\n    )\n\n    is_archived = django_filters.BooleanFilter(\n        widget=ArchivedWidget\n    )\n\n    created = django_filters.NumberFilter(\n        name='created',\n        lookup_expr='year',\n        widget=YearWidget,\n    )\n\n    typ = django_filters.CharFilter(\n        widget=TypeWidget,\n    )\n\n    class Meta:\n        model = project_models.Project\n        fields = ['organisation', 'is_archived', 'created', 'typ']\n\n\nclass ProjectListView(filter_views.FilteredListView):\n    model = project_models.Project\n    paginate_by = 16\n    filter_set = ProjectFilterSet\n\n    def get_queryset(self):\n        return super().get_queryset().filter(is_draft=False)\n", "path": "apps/projects/views.py"}], "after_files": [{"content": "from datetime import datetime\nimport django_filters\nfrom django.apps import apps\nfrom django.conf import settings\nfrom django.utils.translation import ugettext_lazy as _\n\nfrom adhocracy4.filters import views as filter_views\nfrom adhocracy4.filters.filters import DefaultsFilterSet\nfrom adhocracy4.projects import models as project_models\n\nfrom apps.contrib.widgets import DropdownLinkWidget\nfrom apps.dashboard import blueprints\n\n\nclass OrderingWidget(DropdownLinkWidget):\n    label = _('Ordering')\n    right = True\n\n\nclass OrganisationWidget(DropdownLinkWidget):\n    label = _('Organisation')\n\n\nclass ArchivedWidget(DropdownLinkWidget):\n    label = _('Archived')\n\n    def __init__(self, attrs=None):\n        choices = (\n            ('', _('All')),\n            ('false', _('No')),\n            ('true', _('Yes')),\n        )\n        super().__init__(attrs, choices)\n\n\nclass YearWidget(DropdownLinkWidget):\n    label = _('Year')\n\n    def __init__(self, attrs=None):\n        choices = (('', _('Any')),)\n        now = datetime.now().year\n        try:\n            first_year = project_models.Project.objects.earliest('created').\\\n                created.year\n        except project_models.Project.DoesNotExist:\n            first_year = now\n        for year in range(now, first_year - 1, -1):\n            choices += (year, year),\n        super().__init__(attrs, choices)\n\n\nclass TypeWidget(DropdownLinkWidget):\n    label = _('Project Type')\n\n    def __init__(self, attrs=None):\n        choices = (('', _('Any')),)\n        sorted_blueprints = sorted(blueprints.blueprints, key=lambda a: a[1])\n        for blueprint_key, blueprint in sorted_blueprints:\n            choices += (blueprint_key, blueprint.title),\n        super().__init__(attrs, choices)\n\n\nclass ProjectFilterSet(DefaultsFilterSet):\n\n    defaults = {\n        'is_archived': 'false'\n    }\n\n    ordering = django_filters.OrderingFilter(\n        choices=(\n            ('-created', _('Most recent')),\n        ),\n        empty_label=None,\n        widget=OrderingWidget,\n    )\n\n    organisation = django_filters.ModelChoiceFilter(\n        queryset=apps.get_model(settings.A4_ORGANISATIONS_MODEL).objects\n                     .order_by('name'),\n        widget=OrganisationWidget,\n    )\n\n    is_archived = django_filters.BooleanFilter(\n        widget=ArchivedWidget\n    )\n\n    created = django_filters.NumberFilter(\n        name='created',\n        lookup_expr='year',\n        widget=YearWidget,\n    )\n\n    typ = django_filters.CharFilter(\n        widget=TypeWidget,\n    )\n\n    class Meta:\n        model = project_models.Project\n        fields = ['organisation', 'is_archived', 'created', 'typ']\n\n\nclass ProjectListView(filter_views.FilteredListView):\n    model = project_models.Project\n    paginate_by = 16\n    filter_set = ProjectFilterSet\n\n    def get_queryset(self):\n        return super().get_queryset().filter(is_draft=False)\n", "path": "apps/projects/views.py"}]}