Skip to content

Commit

Permalink
use total_cmp for f64
Browse files Browse the repository at this point in the history
  • Loading branch information
PSeitz committed Mar 6, 2024
1 parent e25b9b0 commit cd73728
Showing 1 changed file with 3 additions and 20 deletions.
23 changes: 3 additions & 20 deletions quickwit/quickwit-proto/src/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,6 @@ impl Ord for SortValue {
// Same types.
(SortValue::U64(left), SortValue::U64(right)) => left.cmp(&right),
(SortValue::I64(left), SortValue::I64(right)) => left.cmp(&right),
(SortValue::F64(left), SortValue::F64(right)) => {
if left.is_nan() {
if right.is_nan() {
Ordering::Equal
} else {
Ordering::Less
}
} else if right.is_nan() {
Ordering::Greater
} else {
left.partial_cmp(&right).unwrap_or(Ordering::Less)
}
}
(SortValue::Boolean(left), SortValue::Boolean(right)) => left.cmp(&right),
// We half the logic by making sure we keep
// the "stronger" type on the left.
Expand All @@ -147,13 +134,9 @@ impl Ord for SortValue {
}
(left as i64).cmp(&right)
}
(SortValue::F64(left), _) if left.is_nan() => Ordering::Less,
(SortValue::F64(left), SortValue::U64(right)) => {
left.partial_cmp(&(right as f64)).unwrap_or(Ordering::Less)
}
(SortValue::F64(left), SortValue::I64(right)) => {
left.partial_cmp(&(right as f64)).unwrap_or(Ordering::Less)
}
(SortValue::F64(left), SortValue::F64(right)) => left.total_cmp(&right),
(SortValue::F64(left), SortValue::U64(right)) => left.total_cmp(&(right as f64)),
(SortValue::F64(left), SortValue::I64(right)) => left.total_cmp(&(right as f64)),
(SortValue::Boolean(left), right) => SortValue::U64(left as u64).cmp(&right),
(left, right) => right.cmp(&left).reverse(),
}
Expand Down

0 comments on commit cd73728

Please sign in to comment.