DEV Community

Discussion on: JavaScript One-Liners That Make Me Excited

Collapse
 
sabberworm profile image
Raphael Schweikert • Edited

Be careful with that shuffle, it won’t yield truly random results because sort expects its comparator to uphold Math.sign(compare(a, b)) === -Math.sign(compare(b, a)). Microsoft once screwed up by using exactly that.

Collapse
 
healeycodes profile image
Andrew Healey

What an interesting story! Thanks for sharing.

And yes, for any production code just use Fisher/Yates!