tustvold commented on code in PR #3510:
URL: https://github.com/apache/arrow-rs/pull/3510#discussion_r1067439651


##########
arrow-ord/src/ord.rs:
##########
@@ -21,32 +21,21 @@ use arrow_array::types::*;
 use arrow_array::*;
 use arrow_buffer::ArrowNativeType;
 use arrow_schema::{ArrowError, DataType};
-use num::Float;
 use std::cmp::Ordering;
 
 /// Compare the values at two arbitrary indices in two arrays.
 pub type DynComparator = Box<dyn Fn(usize, usize) -> Ordering + Send + Sync>;
 
-/// compares two floats, placing NaNs at last
-fn cmp_nans_last<T: Float>(a: &T, b: &T) -> Ordering {
-    match (a.is_nan(), b.is_nan()) {
-        (true, true) => Ordering::Equal,
-        (true, false) => Ordering::Greater,
-        (false, true) => Ordering::Less,
-        _ => a.partial_cmp(b).unwrap(),
-    }
-}
-
 fn compare_primitives<T: ArrowPrimitiveType>(
     left: &dyn Array,
     right: &dyn Array,
 ) -> DynComparator
 where
-    T::Native: Ord,
+    T::Native: ArrowNativeTypeOp,
 {
     let left: PrimitiveArray<T> = PrimitiveArray::from(left.data().clone());
     let right: PrimitiveArray<T> = PrimitiveArray::from(right.data().clone());
-    Box::new(move |i, j| left.value(i).cmp(&right.value(j)))
+    Box::new(move |i, j| left.value(i).compare(right.value(j)))

Review Comment:
   👍 regardless this is a good change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to