title: python how to sort a list
body: <p>i have to display a list shift wise like have to first show all day shift results then afternoon then night
  but now it shows afternoon first then night then day
  here is my code</p>
  <p>views.py:</p>
  <pre><code>    def get_queryset(self):
      getall = self.request.GET.get(&quot;getall&quot;)
  
      if self.request.user:
          versions = LogVersion.objects.filter(
              form__airport__id=self.request.user.aerosimple_user.airport_id
          ).exclude(status=DRAFT)
          filters = self.request.GET.get(&quot;filters&quot;)
          tags = self.request.GET.get(&quot;tags&quot;)
  
          logs = Log.objects.none()
          result = Log.objects.none()
  
          for v in versions:
              if len(v.operation_logs.order_by('-id').all())&gt;0:
                  result = result | v.operation_logs.order_by('-id').all()
                  result = result.exclude(shift_name = None).exclude(shift_name='')
  
      # if getall:
          if getall:
              return  Log.objects.filter(
              form__form__airport__id=self.request.user.aerosimple_user.airport.id)
          if filters is not None:
              filters = filters[:-2] if filters[-2:] == ',,' else filters
              filters_list = filters.split(',,')
              for filters in filters_list:
                  log = result.filter(Q(type = filters) | Q(subtype = filters))
                  if filters == 'Inspection Completed':
                      log = result.filter(Q(description = filters))
                  elif log != []:
                      for r in result:
                          if r.tags is not None and filters in r.tags:
                              log  =result.filter(id=r.id)
                  else:
                      log = result.filter(Q(type = filters) | Q(subtype = filters))
                  logs = logs | log
              return logs.all()
          return result
  </code></pre>
  <p>how to sort it correctly</p>