Sorting

PHOTO EMBED

Sun Jul 17 2022 07:11:59 GMT+0000 (Coordinated Universal Time)

Saved by @man_ssorr #javascript

// Better to avoid mutations (that will bite you in libraries like React):
[...stringArr].sort();
[...stringArr].reverse();

// I generally recommend to use `a` and `z` to make it clear:
[...array].sort((a, z) => a - z);
[...array].sort((a, z) => z - a);

// But you could also make it more readable:
[...array].sort((first, second) => first - second);
[...array].sort((first, second) => second - first);
content_copyCOPY