title: template tag is showing duplicate items in template
body: <p>I am building a Blog App and I built a <code>template tag</code> to <code>sort posts by likes</code>. Template tag I working fine, But when I sort <code>by likes</code> then it is showing duplicate items according to likes. I mean, If a post got 3 likes then it is showing that post thee times.</p>
  <p>models.py</p>
  <pre><code>class BlogPost(models.Model):
      user = models.ForeignKey(User, on_delete=models.CASCADE)
      title = models.CharField(max_length=1000)
      body = models.CharField(max_length=1000)
      likes = models.ManyToManyField(User, related_name='likes')
  </code></pre>
  <p>template_tags.py</p>
  <pre><code>from django import template
  
  register = template.Library()
  
  @register.filter
  def sort(queryset, order):
      return queryset.order_by(order)
  </code></pre>
  <p>views.py</p>
  <pre><code>def posts(request):
      posts = BlogPost.objects.filter(user=request.user)
  
      context = {'posts':posts}
      return render(request, 'posts.html', context)
  </code></pre>
  <p>posts.html</p>
  <pre><code>
  {% load template_tags %}
  
  {% block content %}
  
  
  {% for post in posts|sort:'likes' %}
  
  {{post.title}}
  
  {% endfor %}
  
  
  {% endblock content %}
  </code></pre>
  <p>I have also tried by using <code>distinct()</code> in both <code>template_tags.py</code> and <code>views.py</code> but it is making no effect on query.</p>