Script
Scriptβ€’3y ago

Script – 23-27 Jan 30

I'm not understanding this kind of sorting arr = arr.sort((a, b) => a < b ? 1 : -1); What does 1, -1 mean?
6 Replies
ScriptyChris
ScriptyChrisβ€’3y ago
-1 goes for < 0
reactibot
reactibotβ€’3y ago
This question has an answer! Thank you for helping πŸ˜„ If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/937489270631976970
lebouwski
lebouwskiβ€’3y ago
if its for numbers you can just do (a, b) => a - b
Script
Scriptβ€’3y ago
yh thats the one I'm familiar with So I got confused when I saw the ternary with 1 and -1. Thanks
reactibot
reactibotβ€’3y ago
This thread hasn’t had any activity in 12 hours, so it’s now locked. Threads are closed automatically after 12 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/937489270631976970