Repost :
🔢 Quick tip: if you’re sorting an array in JS and keep forgetting how to write the compare functions (like I do), here’s a mnemonic device:
(a, z) => a – z // ascending, like “a to z”
(a, z) => z – a // descending, like “z to a”— David K. 🎹 (@DavidKPiano) August 8, 2020