Given that we an array of articles where each article has a title , description and date . so we have a list of articles that are displayed . Now we have two buttons sort by title and sort by date which should sort the articles when the corresponding button is clicked.
How to implement this functionality ?
In my view I would store the articles array in a state variable and upon clicking the button
I will sort the articles either by title or by date and map through each article to display its content .
Any suggestions or better way to implement this functionality ?
Don’t write the react code just give the pseudo code
Thanks you