You are viewing a single thread.
View all comments
4 points

As annoying as this is, you are meant to use a comparer.

mapped.sort((a, b) => {
  if (a.value > b.value) {
    return 1;
  }
  if (a.value < b.value) {
    return -1;
  }
  return 0;
});
permalink
report
reply
37 points
arr.sort((a, b) => a - b);
permalink
report
parent
reply
2 points

One hundred percent how I do it everytime.

permalink
report
parent
reply
5 points

Stuff like that exists to remind us of the Java in JavaScript

permalink
report
parent
reply

Programmer Humor

!programmer_humor@programming.dev

Create post

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

  • Keep content in english
  • No advertisements
  • Posts must be related to programming or programmer topics

Community stats

  • 7K

    Monthly active users

  • 950

    Posts

  • 35K

    Comments