Linked Questions

Popular Questions

How can I sort items correctly using js

Asked by At

I searched problems similar to this one, but those didn't solve my problem. I have a bootstrap cards showing items. And i have a filter to order this cards by liked votes, but when I trigger the js function, the sort doesnt works well (looks like it's ordering in a random way) .


 <a class="like badge" onclick="vote('{% url 'like_item' %}', '.liked_item_{{}}', '.disliked_item_{{}}', '.like_{{}}', '.dislike_{{}}')" href="javascript:void(0)">
        <span class="liked_item_{{}} liked_votes">
          {{ item.count_likes }}


if( == 'thumbsUp'){
    var thumbsUpOrderedDivs = $divs.sort(function (a, b) {
        return $(a).find('.liked_votes').text() < $(b).find('.liked_votes').text();

Related Questions