Skip to content

compareNaturalAscending

compareNaturalAscending<T>(a, b): ComparatorResult

Defined in: packages/core/src/function/compare/compare-natural.ts:18

Ascending natural order, using the < and > operators.

Exact — no tolerance of any kind. Two numbers compare equivalent only when === says so, which is what keeps this a strict weak ordering; an approximate comparison is not transitive and would corrupt every sort, bisect and heap it reached. Use isCloseTo for approximate tests, and never as a comparator.

NaN sorts after every other value and is equivalent to itself, so the ordering stays total. -0 and +0 are equivalent, matching === and therefore agreeing with exact equality — deliberately unlike %TypedArray%.prototype.sort, which orders -0 before +0 and so cannot agree with an ===-based equality.

T

T

T

ComparatorResult