title: how to sort object in django
body: <pre><code>def bubble_sort(nts):
  nts_len = len(nts)
  for i in range(nts_len):
      for p in range(nts_len - i - 1):
          if nts[p] &lt; nts[p+1]:
              t = nts[p]
              nts[p]= nts[p+1]
              nts[p+1] = t
  return nts
  def menu(request):
  products = Product.objects.all()
  if request.method == &quot;POST&quot;:
      s = request.POST['select']
      if s == 'Price: Low to High':
          element = []
          for var in products:
              element.append(var)
          list_items = list(element)
          bb = bubble_sort(list_items)
          el = list(bb)
          print(el)
          
          pro = Product.objects.filter(id__in=bb)
          print(pro)
          products = bb
  
          # print(products)
     
  </code></pre>
  <p><strong>How to retrieve data from database in bubble sort for objects?TypeError: '&lt;' not supported between instances of 'Product' and 'Product'</strong></p>