betodealmeida commented on a change in pull request #17573:
URL: https://github.com/apache/superset/pull/17573#discussion_r759694939



##########
File path: superset-frontend/src/components/FilterableTable/FilterableTable.tsx
##########
@@ -323,19 +323,19 @@ export default class FilterableTable extends 
PureComponent<
 
   sortResults(sortBy: string, descending: boolean) {
     return (a: Datum, b: Datum) => {
-      const aValue = a[sortBy];
-      const bValue = b[sortBy];
-      if (aValue === bValue) {
-        // equal items sort equally
-        return 0;
-      }
-      if (aValue === null) {
-        // nulls sort after anything else
-        return 1;
-      }
-      if (bValue === null) {
-        return -1;
-      }
+      // Parse any floating numbers so they'll sort correctly
+      const parseFloatingNums = (value: any) => {
+        const floatValue = parseFloat(value);
+        return Number.isNaN(floatValue) ? value : parseFloat(value);
+      };

Review comment:
       I think it's better to move this function outside of `sortResults`, 
otherwise it gets defined for every comparison when sorting the array.

##########
File path: superset-frontend/src/components/FilterableTable/FilterableTable.tsx
##########
@@ -323,19 +323,19 @@ export default class FilterableTable extends 
PureComponent<
 
   sortResults(sortBy: string, descending: boolean) {
     return (a: Datum, b: Datum) => {
-      const aValue = a[sortBy];
-      const bValue = b[sortBy];
-      if (aValue === bValue) {
-        // equal items sort equally
-        return 0;
-      }
-      if (aValue === null) {
-        // nulls sort after anything else
-        return 1;
-      }
-      if (bValue === null) {
-        return -1;
-      }

Review comment:
       This is still needed, right? So that `null` sort after non-null values?




-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to