I have an element of the sidebar, on the page of my application I want to sort them by the number of likes. How can I implement sorting at the stage of the map operation, so that the components are drawn correctly?
return (
<section>
<Popular/>
<div>
{this.props.object.map((summary, i) =>
<SideBarPost id={summary.id}
firstName={summary.User.firstName}
lastName={summary.User.lastName}
title={summary.title}
createdAt={summary.createdAt}
likes={summary.likes.length}
key={i}
/>)
}
</div>
</section>