const mostLikes = (array) => { const authorsAndLikesArray = _(array) .groupBy("author") .map((objs, key) => ({ author: key, totalLikes: _.sumBy(objs, "likes"), })) .value(); const sorted = _.sortBy(authorsAndLikesArray, "totalLikes").reverse(); return sorted };