raminqaf commented on code in PR #28155:
URL: https://github.com/apache/flink/pull/28155#discussion_r3246735058


##########
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/functions/scalar/ArraySortFunction.java:
##########
@@ -109,8 +109,14 @@ public ArraySortComparator(boolean isAscending) {
         @Override
         public int compare(Object o1, Object o2) {
             try {
-                boolean isGreater = (boolean) greaterHandle.invoke(o1, o2);
-                return isAscending ? (isGreater ? 1 : -1) : (isGreater ? -1 : 
1);
+                // Two probes so equal elements return 0 (Comparator contract).
+                if ((boolean) greaterHandle.invoke(o1, o2)) {
+                    return isAscending ? 1 : -1;

Review Comment:
   Nit one:
   maybe we can extract this into a variable and re-use it
   ```java
   int sign = isAscending ? 1 : -1;
   
   if ((boolean) greaterHandle.invoke(o1, o2)) return sign;
   
   if ((boolean) greaterHandle.invoke(o2, o1)) return -sign;
   
   return 0;
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to