constructor(props) {
super(props);
let comments = [{body: "good", created_at:"2018-02-12T05:27:47.175Z"},
{body: "bad article", created_at:"2017-11-12T05:27:47.175Z"},
{body: "great", created_at:"2017-10-12T05:27:47.175Z"}];
this.state = { comments };
render() {
return(
{ comments.map((comment, index) =>
<Text>{comment.body}</Text>
)}
);
};
The data comes in descending order but, I want to sort it in ascending order based on created_at
date.
Now, comment which is new is coming first and I want comment which is old should come first.
How can I sort this comments? Please suggest any solution.