...

/

Advanced Sorting: implementing reverse sort

Advanced Sorting: implementing reverse sort

In this lesson, you'll continue to implement our advanced data sorting technique. By the end of this lesson, we will be able to sort and reverse sort our app's table by column

We'll cover the following...

In the previous lesson, we did some initial ground work to get our search functionality working. In this chapter, we’ll finish the sort functionality with reverse sort. The list should perform a reverse sort once you click a Sort component twice. First, you need to define the reverse state with a boolean. The sort can be either reversed or non-reversed.

Press + to interact
this.state = {
results: null,
searchKey: '',
searchTerm: DEFAULT_QUERY,
error: null,
isLoading: false,
sortKey: 'NONE',
isSortReverse: false,
};

Now in your sort method, you can evaluate if the list is reverse sorted. It is reverse if the sortKey in the state is the same as ...