prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Sort list of schemas
  On the Database Page, the schemas appear in random order.
  
  ![image](https://user-images.githubusercontent.com/42411/199863005-2cc007c5-3224-489b-86de-80d924010833.png)
  
  I think they should be listed alphabetically, perhaps with `public` first.
  
  I'm not sure whether it would be better to handle this on the back end or the front end.
  
  Any thoughts @mathemancer @rajatvijay?
  
  
  Update:
  * This issue is supposed to be handled on the backend.
  * Part of this issue is solved in https://github.com/centerofci/mathesar/pull/2062
  * Refer https://github.com/centerofci/mathesar/issues/1897#issuecomment-1470542703 for the current state of the issue.
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `mathesar/api/db/viewsets/schemas.py`
  Content:
  ```
  1 from django_filters import rest_framework as filters
  2 from rest_access_policy import AccessViewSetMixin
  3 from rest_framework import status, viewsets
  4 from rest_framework.decorators import action
  5 from rest_framework.mixins import ListModelMixin, RetrieveModelMixin
  6 from rest_framework.response import Response
  7 
  8 from mathesar.api.db.permissions.schema import SchemaAccessPolicy
  9 from mathesar.api.dj_filters import SchemaFilter
  10 from mathesar.api.pagination import DefaultLimitOffsetPagination
  11 from mathesar.api.serializers.dependents import DependentSerializer, DependentFilterSerializer
  12 from mathesar.api.serializers.schemas import SchemaSerializer
  13 from mathesar.models.base import Schema
  14 from mathesar.utils.schemas import create_schema_and_object
  15 
  16 
  17 class SchemaViewSet(AccessViewSetMixin, viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin):
  18     serializer_class = SchemaSerializer
  19     pagination_class = DefaultLimitOffsetPagination
  20     filter_backends = (filters.DjangoFilterBackend,)
  21     filterset_class = SchemaFilter
  22     access_policy = SchemaAccessPolicy
  23 
  24     def get_queryset(self):
  25         qs = Schema.objects.all().order_by('-created_at')
  26         return self.access_policy.scope_viewset_queryset(self.request, qs)
  27 
  28     def create(self, request):
  29         serializer = SchemaSerializer(data=request.data, context={'request': request})
  30         serializer.is_valid(raise_exception=True)
  31         database_name = serializer.validated_data['database'].name
  32         schema = create_schema_and_object(
  33             serializer.validated_data['name'],
  34             database_name,
  35             comment=serializer.validated_data.get('description')
  36         )
  37         serializer = SchemaSerializer(schema)
  38         return Response(serializer.data, status=status.HTTP_201_CREATED)
  39 
  40     def partial_update(self, request, pk=None):
  41         serializer = SchemaSerializer(
  42             data=request.data, context={'request': request}, partial=True
  43         )
  44         serializer.is_valid(raise_exception=True)
  45 
  46         schema = self.get_object()
  47         schema.update_sa_schema(serializer.validated_data)
  48 
  49         # Reload the schema to avoid cached properties
  50         schema = self.get_object()
  51         schema.clear_name_cache()
  52         serializer = SchemaSerializer(schema, context={'request': request})
  53         return Response(serializer.data)
  54 
  55     def destroy(self, request, pk=None):
  56         schema = self.get_object()
  57         schema.delete_sa_schema()
  58         return Response(status=status.HTTP_204_NO_CONTENT)
  59 
  60     @action(methods=['get'], detail=True)
  61     def dependents(self, request, pk=None):
  62         serializer = DependentFilterSerializer(data=request.GET)
  63         serializer.is_valid(raise_exception=True)
  64         types_exclude = serializer.validated_data['exclude']
  65 
  66         schema = self.get_object()
  67         serializer = DependentSerializer(schema.get_dependents(types_exclude), many=True, context={'request': request})
  68         return Response(serializer.data)
  69
  ```
  --- 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/mathesar/api/db/viewsets/schemas.py b/mathesar/api/db/viewsets/schemas.py
  --- a/mathesar/api/db/viewsets/schemas.py
  +++ b/mathesar/api/db/viewsets/schemas.py
  @@ -22,7 +22,7 @@
       access_policy = SchemaAccessPolicy
   
       def get_queryset(self):
  -        qs = Schema.objects.all().order_by('-created_at')
  +        qs = Schema.objects.all().order_by('name')
           return self.access_policy.scope_viewset_queryset(self.request, qs)
   
       def create(self, request):
  
verification_info: {"golden_diff": "diff --git a/mathesar/api/db/viewsets/schemas.py b/mathesar/api/db/viewsets/schemas.py\n--- a/mathesar/api/db/viewsets/schemas.py\n+++ b/mathesar/api/db/viewsets/schemas.py\n@@ -22,7 +22,7 @@\n     access_policy = SchemaAccessPolicy\n \n     def get_queryset(self):\n-        qs = Schema.objects.all().order_by('-created_at')\n+        qs = Schema.objects.all().order_by('name')\n         return self.access_policy.scope_viewset_queryset(self.request, qs)\n \n     def create(self, request):\n", "issue": "Sort list of schemas\nOn the Database Page, the schemas appear in random order.\r\n\r\n![image](https://user-images.githubusercontent.com/42411/199863005-2cc007c5-3224-489b-86de-80d924010833.png)\r\n\r\nI think they should be listed alphabetically, perhaps with `public` first.\r\n\r\nI'm not sure whether it would be better to handle this on the back end or the front end.\r\n\r\nAny thoughts @mathemancer @rajatvijay?\r\n\r\n\r\nUpdate:\r\n* This issue is supposed to be handled on the backend.\r\n* Part of this issue is solved in https://github.com/centerofci/mathesar/pull/2062\r\n* Refer https://github.com/centerofci/mathesar/issues/1897#issuecomment-1470542703 for the current state of the issue.\n", "before_files": [{"content": "from django_filters import rest_framework as filters\nfrom rest_access_policy import AccessViewSetMixin\nfrom rest_framework import status, viewsets\nfrom rest_framework.decorators import action\nfrom rest_framework.mixins import ListModelMixin, RetrieveModelMixin\nfrom rest_framework.response import Response\n\nfrom mathesar.api.db.permissions.schema import SchemaAccessPolicy\nfrom mathesar.api.dj_filters import SchemaFilter\nfrom mathesar.api.pagination import DefaultLimitOffsetPagination\nfrom mathesar.api.serializers.dependents import DependentSerializer, DependentFilterSerializer\nfrom mathesar.api.serializers.schemas import SchemaSerializer\nfrom mathesar.models.base import Schema\nfrom mathesar.utils.schemas import create_schema_and_object\n\n\nclass SchemaViewSet(AccessViewSetMixin, viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin):\n    serializer_class = SchemaSerializer\n    pagination_class = DefaultLimitOffsetPagination\n    filter_backends = (filters.DjangoFilterBackend,)\n    filterset_class = SchemaFilter\n    access_policy = SchemaAccessPolicy\n\n    def get_queryset(self):\n        qs = Schema.objects.all().order_by('-created_at')\n        return self.access_policy.scope_viewset_queryset(self.request, qs)\n\n    def create(self, request):\n        serializer = SchemaSerializer(data=request.data, context={'request': request})\n        serializer.is_valid(raise_exception=True)\n        database_name = serializer.validated_data['database'].name\n        schema = create_schema_and_object(\n            serializer.validated_data['name'],\n            database_name,\n            comment=serializer.validated_data.get('description')\n        )\n        serializer = SchemaSerializer(schema)\n        return Response(serializer.data, status=status.HTTP_201_CREATED)\n\n    def partial_update(self, request, pk=None):\n        serializer = SchemaSerializer(\n            data=request.data, context={'request': request}, partial=True\n        )\n        serializer.is_valid(raise_exception=True)\n\n        schema = self.get_object()\n        schema.update_sa_schema(serializer.validated_data)\n\n        # Reload the schema to avoid cached properties\n        schema = self.get_object()\n        schema.clear_name_cache()\n        serializer = SchemaSerializer(schema, context={'request': request})\n        return Response(serializer.data)\n\n    def destroy(self, request, pk=None):\n        schema = self.get_object()\n        schema.delete_sa_schema()\n        return Response(status=status.HTTP_204_NO_CONTENT)\n\n    @action(methods=['get'], detail=True)\n    def dependents(self, request, pk=None):\n        serializer = DependentFilterSerializer(data=request.GET)\n        serializer.is_valid(raise_exception=True)\n        types_exclude = serializer.validated_data['exclude']\n\n        schema = self.get_object()\n        serializer = DependentSerializer(schema.get_dependents(types_exclude), many=True, context={'request': request})\n        return Response(serializer.data)\n", "path": "mathesar/api/db/viewsets/schemas.py"}], "after_files": [{"content": "from django_filters import rest_framework as filters\nfrom rest_access_policy import AccessViewSetMixin\nfrom rest_framework import status, viewsets\nfrom rest_framework.decorators import action\nfrom rest_framework.mixins import ListModelMixin, RetrieveModelMixin\nfrom rest_framework.response import Response\n\nfrom mathesar.api.db.permissions.schema import SchemaAccessPolicy\nfrom mathesar.api.dj_filters import SchemaFilter\nfrom mathesar.api.pagination import DefaultLimitOffsetPagination\nfrom mathesar.api.serializers.dependents import DependentSerializer, DependentFilterSerializer\nfrom mathesar.api.serializers.schemas import SchemaSerializer\nfrom mathesar.models.base import Schema\nfrom mathesar.utils.schemas import create_schema_and_object\n\n\nclass SchemaViewSet(AccessViewSetMixin, viewsets.GenericViewSet, ListModelMixin, RetrieveModelMixin):\n    serializer_class = SchemaSerializer\n    pagination_class = DefaultLimitOffsetPagination\n    filter_backends = (filters.DjangoFilterBackend,)\n    filterset_class = SchemaFilter\n    access_policy = SchemaAccessPolicy\n\n    def get_queryset(self):\n        qs = Schema.objects.all().order_by('name')\n        return self.access_policy.scope_viewset_queryset(self.request, qs)\n\n    def create(self, request):\n        serializer = SchemaSerializer(data=request.data, context={'request': request})\n        serializer.is_valid(raise_exception=True)\n        database_name = serializer.validated_data['database'].name\n        schema = create_schema_and_object(\n            serializer.validated_data['name'],\n            database_name,\n            comment=serializer.validated_data.get('description')\n        )\n        serializer = SchemaSerializer(schema)\n        return Response(serializer.data, status=status.HTTP_201_CREATED)\n\n    def partial_update(self, request, pk=None):\n        serializer = SchemaSerializer(\n            data=request.data, context={'request': request}, partial=True\n        )\n        serializer.is_valid(raise_exception=True)\n\n        schema = self.get_object()\n        schema.update_sa_schema(serializer.validated_data)\n\n        # Reload the schema to avoid cached properties\n        schema = self.get_object()\n        schema.clear_name_cache()\n        serializer = SchemaSerializer(schema, context={'request': request})\n        return Response(serializer.data)\n\n    def destroy(self, request, pk=None):\n        schema = self.get_object()\n        schema.delete_sa_schema()\n        return Response(status=status.HTTP_204_NO_CONTENT)\n\n    @action(methods=['get'], detail=True)\n    def dependents(self, request, pk=None):\n        serializer = DependentFilterSerializer(data=request.GET)\n        serializer.is_valid(raise_exception=True)\n        types_exclude = serializer.validated_data['exclude']\n\n        schema = self.get_object()\n        serializer = DependentSerializer(schema.get_dependents(types_exclude), many=True, context={'request': request})\n        return Response(serializer.data)\n", "path": "mathesar/api/db/viewsets/schemas.py"}]}