prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <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.
  
  </issue>
  <code>
  [start of mathesar/api/db/viewsets/schemas.py]
  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 of mathesar/api/db/viewsets/schemas.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
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"}]}