Sorting Arrays

sort puts an array in order, but it compares items as text unless you give it a compare function, and it changes the array itself, so toSorted is the way to get a sorted copy and keep the original.

Updated

Cheat sheet: Sorting Arrays
Category
JavaScript
Level
Apprentice
Tags
Compare Function (javascript), Immutability, JavaScript, slice(), sort() (javascript), toSorted() (javascript)