In this lesson we cover all the details of how to sort a list of items using TypeScript. There are a few things that will catch beginner developers off guard, such as the
.sort method mutating your array, and how the
.sort method doesn’t sort numbers how you’d expect.
You'll learn these gotcha’s and how to work around them.
We’ll also present a few tricks to make your sort logic more readable and maintainable using TypeScript.
What ide/editor are you using there man. Nice code complete.
Your description of the sort function is misleading. It is not a < b then return negative. It is if a is first in sort order then return negative. That is why
(a, b) => b - a sorts in descending order.