[std/collections] sortBy returns strange result if selector returns NaN sometimes
See original GitHub issueBecause 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:
- Created 2 years ago
- Comments:8 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@LionC It has to be in the description, not the title.
Hm apparently an MR referencing to this being merged does not close the issue automatically.
@kt3k can you close this?