Compare two Values with type coercion. Tries numeric comparison first (with bool coercion), then falls back to string comparison.
(a: &Value, b: &Value)
| 35 | /// Tries numeric comparison first (with bool coercion), then falls |
| 36 | /// back to string comparison. |
| 37 | pub fn compare_values(a: &Value, b: &Value) -> Ordering { |
| 38 | if let (Some(na), Some(nb)) = (value_to_f64(a, true), value_to_f64(b, true)) { |
| 39 | return na.partial_cmp(&nb).unwrap_or(Ordering::Equal); |
| 40 | } |
| 41 | let sa = value_to_display_string(a); |
| 42 | let sb = value_to_display_string(b); |
| 43 | sa.cmp(&sb) |
| 44 | } |
| 45 | |
| 46 | /// Check equality with type coercion. |
| 47 | /// |
no test coverage detected