From e62af4d65c6c1b0638bb009b71255a14d950cb44 Mon Sep 17 00:00:00 2001 From: Patrick Browne Date: Tue, 27 Sep 2022 10:17:32 +0200 Subject: [PATCH] feat: Use sort by for clarity --- app/configurator/configurator-state.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/configurator/configurator-state.tsx b/app/configurator/configurator-state.tsx index 8c45f917a..ec2ad48c6 100644 --- a/app/configurator/configurator-state.tsx +++ b/app/configurator/configurator-state.tsx @@ -3,6 +3,7 @@ import get from "lodash/get"; import mapValues from "lodash/mapValues"; import pickBy from "lodash/pickBy"; import setWith from "lodash/setWith"; +import sortBy from "lodash/sortBy"; import { useRouter } from "next/router"; import { createContext, @@ -352,8 +353,8 @@ export const deriveFiltersFromFields = produce( const isField = (iri: string) => fieldDimensionIris.has(iri); // Apply hierarchical dimensions first - const sortedDimensions = [...dimensions].sort( - (a, b) => (a.hierarchy ? -1 : 1) - (b.hierarchy ? -1 : 1) + const sortedDimensions = sortBy(dimensions, (d) => + d.hierarchy ? -1 : 1 ); sortedDimensions.forEach((dimension) => applyNonTableDimensionToFilters({