Better way of custom sorting difficulty filters
This commit is contained in:
committed by
fabioberger
parent
635b80440a
commit
53b4f48b2e
@@ -36,8 +36,8 @@ const FiltersList: React.FC<IFilterListProps> = ({
|
||||
const sortAlphabetically = (items: IFilterProps[]) => _.orderBy(items, 'label', 'asc');
|
||||
|
||||
const sortByDifficulty = (items: IFilterProps[]) => {
|
||||
const findItem = (label: string) => items.find((item: IFilterProps) => item.label === label);
|
||||
return [findItem('Beginner'), findItem('Intermediate'), findItem('Advanced')];
|
||||
const order = ['Beginner', 'Intermediate', 'Advanced'];
|
||||
return items.sort((a, b) => order.indexOf(a.label) - order.indexOf(b.label));
|
||||
};
|
||||
|
||||
const sortFilters = (items: IFilterProps[]) =>
|
||||
|
||||
Reference in New Issue
Block a user