Skip to main content

compare

Function compare 

Source
pub fn compare(left: &Value, right: &Value) -> Option<Ordering>
Expand description

Orders two JSON values by the expression language’s OWN ordering rule, the one <, <=, >, and >= are defined by: two numbers compare by mathematical value (exactly through i128 when both are integral, as f64 when either is fractional), two strings compare lexicographically, and every other pairing is unordered (None).

Exported because a second consumer needs the identical order: a fold node’s FoldJoin::BestBy is an argmax over the passes, and an argmax that ordered values even slightly differently from the stop_when predicate beside it would make one node speak two languages. Calling this is what keeps the two from ever drifting; re-deriving the rule would not.

None also answers “is this value orderable at all”, because a value orders against itself exactly when its type is one this rule orders. That is the check a best_by argmax needs to decide which passes may win, and it needs no type list of its own.