Glossary: Data Structures and Algorithms in JavaScript
toSorted / sort
Also written: toSorted, sort
toSorted returns a new sorted array, while sort sorts the array itself. Without a compare function both sort as strings, so numbers come out in the wrong order.