this post was submitted on 05 Sep 2023
917 points (98.7% liked)

Programmer Humor

19480 readers
175 users here now

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

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 4 points 1 year ago (3 children)

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;
});
[–] [email protected] 37 points 1 year ago (1 children)
[–] [email protected] 2 points 1 year ago

One hundred percent how I do it everytime.

load more comments (1 replies)