...
/Crafting a Generic Sort Function
Crafting a Generic Sort Function
Build a generic sort function in TypeScript.
We'll cover the following...
We'll cover the following...
What does sort look like?
To get started with our genericSort, let’s think about what sort might look like when it’s used in our component. For example, when we’re rendering the widgets, we can imagine using our genericSort function like this:
<h2>Widgets:</h2>{widgets.sort((a, b) => genericSort(a, b, "title"))}
First, we call JavaScript’s built-in ...