You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/01/12 00:26:15 UTC

[GitHub] [superset] ktmud commented on a change in pull request #18006: fix: SQL Lab sorting of non-numbers

ktmud commented on a change in pull request #18006:
URL: https://github.com/apache/superset/pull/18006#discussion_r782620360



##########
File path: superset-frontend/src/components/FilterableTable/FilterableTable.tsx
##########
@@ -322,16 +322,26 @@ export default class FilterableTable extends PureComponent<
     );
   }
 
-  // Parse any floating numbers so they'll sort correctly
-  parseFloatingNums = (value: any) => {
-    const floatValue = parseFloat(value);
-    return Number.isNaN(floatValue) ? value : floatValue;
+  // Parse any numbers from strings so they'll sort correctly
+  parseNumberFromString = (value: string | number | null) => {
+    if (typeof value === 'string') {
+      // This regex handles all possible number formats in javascript, including ints, floats,
+      // exponential notation, NaN, and Infinity.
+      // See https://stackoverflow.com/a/30987109 for more details
+      const onlyNumberRegEx =
+        /^(NaN|-?((\d*\.\d+|\d+)([Ee][+-]?\d+)?|Infinity))$/;

Review comment:
       Maybe move this to a global constant or create a helper function?




-- 
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-unsubscribe@superset.apache.org

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



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