I have done this in React class components but I need to do this in react function component as I want to learn to convert class components to function components.
onSortByPlatformAsc = () => {
var sortByPlatform = this.state.listGames.sort((a, b) =>
a.platform.localeCompare(b.platform)
);
this.setState({ listGames: sortByPlatform });
};
onSortByPlatformDesc = () => {
var sortByPlatform = this.state.listGames.sort((a, b) =>
a.platform.localeCompare(b.platform)
);
this.setState({ listGames: sortByPlatform.reverse() });
};