question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[std/collections] sortBy returns strange result if selector returns NaN sometimes

See original GitHub issue

Because NaN can’t be compared correctly with other numbers, the output becomes broken when the selector returns NaN sometimes.

For example, the following outputs [NaN, 1, NaN, 5, 7, NaN, 2, 6, 9]

import { sortBy } from "./collections/sort_by.ts";

console.log(sortBy([NaN, 1, NaN, 7, NaN, 2, 6, 5, 9], (x) => x));

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
nayeemrmncommented, Aug 6, 2021

@LionC It has to be in the description, not the title.

1reaction
LionCcommented, Aug 6, 2021

Hm apparently an MR referencing to this being merged does not close the issue automatically.

@kt3k can you close this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python: sort function breaks in the presence of nan
I understand nan is a weird object, so I wouldn't be surprised if it shows up in random places in the sort result....
Read more >
Inconsistent sort order for NaN values across browsers #3718
Ok so the spec reason is that you're violating the sorting compare function contract. If comparefn is not undefined and is not a...
Read more >
AFNI program: 3dcalc
Use 3dTstat to averaging across sub-bricks in a single dataset. 2. Perform arithmetic calculations between the sub-bricks of a single dataset by noting...
Read more >
Single-Page API Reference | Google Earth Engine
Limit a collection to the specified number of elements, optionally sorting them by a specified property first. Returns the limited collection.
Read more >
R Language Definition
The R specific function typeof returns the type of an R object. ... A single element of a character vector is often referred...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found