Skip to main content

compare_cells

Function compare_cells 

Source
pub fn compare_cells(a: &CellValue, b: &CellValue) -> Ordering
Expand description

Total deterministic ordering for CellValue.

Behavior:

  • Same-kind numeric values compare numerically; decimals use f64::total_cmp so NaN is ordered consistently (after all finite values, and 0.0 before -0.0 is reversed by total_cmp semantics — we keep that contract).
  • Mixed Integer / Decimal pairs compare numerically.
  • None always sorts before every other variant.
  • Cross-type non-numeric pairs fall back to a stable type-rank order so the return value is never Equal for genuinely different values.

Use std::cmp::Ordering directly via slice::sort_by; do not rely on whatever a future PartialOrd derive might produce.