Created
January 14, 2022 07:36
-
-
Save khle/b7c774a0204caf3fb96443a702e93aac to your computer and use it in GitHub Desktop.
Step 7
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 User { | |
firstName: string | |
lastName: string | |
} | |
function compareUsers(self: User, other: User): boolean { | |
return self.firstName === other.firstName && self.lastName === other.lastName | |
} | |
const users = [ | |
{ firstName: "Jane", lastName: "Foo" }, | |
{ firstName: "John", lastName: "Bar" }, | |
{ firstName: "Jill", lastName: "Err" }, | |
] | |
const shouldbeFirst = { | |
firstName: "John", | |
lastName: "Bar", | |
compare: compareUsers, | |
} | |
const reArrangedUsers = findMatchingAndMoveToFirst(users, shouldbeFirst) | |
console.log(reArrangedUsers) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment