Challenge: Reverse Sort

Try to sort in reverse order in a react app.

We'll cover the following


The sort feature works, but the ordering only includes one direction. Implement a reverse sort when the button is clicked twice, so it becomes a toggle between normal (ascending) and reverse (descending) sort.

Optional Hints:

  • Consider that reverse or normal sort could be just another state (e.g. isReverse) next to the sortKey.
  • Set the new state in the handleSort handler based on the previous sort.
  • Use the new isReverse state for sorting the list with the sort function from the dictionary with the optionally applied reverse() function from JavaScript arrays.

Get hands-on with 1200+ tech skills courses.