---
title: "Comment by Favourite Jome on \"JavaScript Sort() Method Principles, Use-Cases, and Tasks\" | Hashnode"
description: "Nicely written UBB, I don&#39;t know if I&#39;m correct, in your formula you wrote likes + comments , but I couldn&#39;t sort but likes and comments without bre"
url: "https://hashnode.com/posts/javascript-sort-method-principles-use-cases-and-tasks/61284e9322e1ba252a8804af/comment/612bcfca2858872661b9bf07"
---

[Discussion](https://hashnode.com/posts/javascript-sort-method-principles-use-cases-and-tasks/61284e9322e1ba252a8804af)

Comment [JavaScript Sort() Method Principles, Use-Cases, and Tasks](https://hashnode.com/posts/javascript-sort-method-principles-use-cases-and-tasks/61284e9322e1ba252a8804af)

[Favourite Jome](https://hashnode.com/@Favourite)

[Aug 29, 2021](https://hashnode.com/posts/javascript-sort-method-principles-use-cases-and-tasks/61284e9322e1ba252a8804af/comment/612bcfca2858872661b9bf07)

Nicely written UBB, I don't know if I'm correct, in your formula you wrote _likes + comments_, but I couldn't sort but likes and comments without breaking one.

So I only checked for likes...

```
const descendingLikes = (array) => {
  return array.sort((a, b) => {
    return a.likes - b.likes 
  });
};

const ascendingLikes = (array) => {
  return array.sort((a, b) => {
    return b.likes - a.likes;
  });
};

console.log(descendingLikes(blogPosts))
console.log(ascendingLikes(blogPosts))
```

[Ayodele Samuel Adebayo](https://hashnode.com/@unclebigbay)

[Aug 29, 2021](https://hashnode.com/posts/javascript-sort-method-principles-use-cases-and-tasks/61284e9322e1ba252a8804af/comment/612bcfca2858872661b9bf07#reply-612bdc47fd0bf8636d76e45c)

Well-done Favourite.

I understand what you're saying

But here's the problem we're trying to solve.

Imagine I have 2 likes and 3 comments on my blog post for today

You on the other end have 10 likes and 2 comments

Someone else is having 2 likes and 3 comments as me

Since we're sorting based on the blog post that has the most interactions

Hint 👇

(a.likes + a.comments)

I hope this helps

Let me know if this helps
