Created
January 14, 2022 07:45
-
-
Save khle/eb912a883176be9e609f66fc7c2df8b9 to your computer and use it in GitHub Desktop.
Product
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { findMatchingAndMoveToFirst } from "./findMatchingAndMoveToFirst" | |
interface Product{ | |
name: string | |
description: string | |
price: number | |
} | |
function compareProducts(self: Product, other: Product): boolean { | |
return self.name === other.name && self.description === other.description && self.price === other.price | |
} | |
const products: Product[] = [...] | |
const shouldbeFirst = { | |
... | |
compare: compareProducts, | |
} | |
const reArrangedProducts = findMatchingAndMoveToFirst(products, shouldbeFirst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment