[SR-1990] Sort has incorrect result on small collections with NaN values #44599
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
standard library
Area: Standard library umbrella
Environment
swift/master
Additional Detail from JIRA
md5: 1e24ceab6b5543ae4fa3b7ac98bf9564
relates to:
Issue Description:
When sorting an array of floating-point values, an NaN value will "reset" sorting for a collection with fewer than 20 elements.
sort() opts into an insertion sort at that size, which uses !(a[i] < a[i - 1]) to test whether an element at i is sorted correctly. Since (NaN < x) is false for all x, that's always true.
The text was updated successfully, but these errors were encountered: