kgabryje commented on code in PR #34858:
URL: https://github.com/apache/superset/pull/34858#discussion_r2306938416


##########
superset-frontend/src/explore/components/controls/SelectControl.jsx:
##########
@@ -87,6 +87,56 @@ const defaultProps = {
   valueKey: 'value',
 };
 
+const numberComparator = (a, b) => {
+  const aVal = typeof a.value === 'number' ? a.value : parseFloat(a.value);
+  const bVal = typeof b.value === 'number' ? b.value : parseFloat(b.value);
+  return aVal - bVal;
+};
+
+export const areAllChoiceValuesNumbers = (choices, valueKey = 'value') => {
+  if (!choices || choices.length === 0) {
+    return false;
+  }
+  return choices.every(c => {
+    if (Array.isArray(c)) {
+      const [value] = c;
+      return typeof value === 'number';
+    }
+    if (typeof c === 'object' && c !== null) {
+      return typeof c[valueKey] === 'number';
+    }
+    return typeof c === 'number';
+  });
+};
+
+export const areAllOptionValuesNumbers = (options, valueKey = 'value') => {
+  if (!options || options.length === 0) {
+    return false;
+  }
+  return options.every(o => typeof o[valueKey] === 'number');
+};
+
+export const getSortComparator = (
+  choices,

Review Comment:
   Nope, it's a jsx file 🙂 



-- 
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: notifications-unsubscr...@superset.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org
For additional commands, e-mail: notifications-h...@superset.apache.org

Reply via email to