πŸ’ͺ YASSS! Found the best way to merge accounts array with comments and posts array for Most Comments and Most Posts leaderboard on /community page

The most performant way to merge the accounts array with all the leaderboards on the /community page is to use forEach() and push() after using Object.entries() but before splice.sort.slice()

const sortedArr = Object.entries(sorted)

const sortedArrWithAcc = []
sortedArr.forEach(function (element) {
sortedArrWithAcc.push({
id: element[0],
postsArray: element[1],
account: accountsall.find(
(e) => e.author.id === parseInt(element[0])
),
})
})
this.mostPosts = sortedArrWithAcc
.splice(0, 99999)
.sort((a, b) => b.postsArray.length - a.postsArray.length)
.slice(0, 99999)