From 969a8e78cc7bb5c6901b06b505e25a2c0e974080 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 26 Oct 2020 21:06:36 -0300 Subject: [PATCH] Re Sorting --- pages/index.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pages/index.tsx b/pages/index.tsx index 5304f691e..eb83a6520 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -61,10 +61,10 @@ export default function Home({ // products, then fill them with products from the products list, this // is useful for new commerce sites that don't have a lot of products return { - featured: rangeMap( - 6, - (i) => featuredProducts[i] ?? products.shift() - ).filter(nonNullable), + featured: rangeMap(6, (i) => featuredProducts[i] ?? products.shift()) + .filter(nonNullable) + .sort((a, b) => a.node.prices.price.value - b.node.prices.price.value) + .reverse(), bestSelling: rangeMap( 6, (i) => bestSellingProducts[i] ?? products.shift() @@ -87,7 +87,7 @@ export default function Home({ ))} - {bestSelling.slice(0, 3).map(({ node }) => ( + {bestSelling.slice(3, 6).map(({ node }) => ( - {bestSelling.slice(3, 6).map(({ node }) => ( + {bestSelling.slice(0, 3).map(({ node }) => (