eschutho commented on a change in pull request #11012:
URL: 
https://github.com/apache/incubator-superset/pull/11012#discussion_r495297892



##########
File path: superset-frontend/src/components/AlteredSliceTag.jsx
##########
@@ -90,11 +101,35 @@ export default class AlteredSliceTag extends 
React.Component {
     return diffs;
   }
 
+  sortData = ({ sortBy }) => {
+    if (this.state.rows.length > 0 && sortBy.length > 0) {
+      const { id, desc } = sortBy[0];
+      this.setState(({ rows }) => ({
+        rows: this.sortDataByColumn(rows, id, desc),
+      }));
+    }
+  };
+
+  sortDataByColumn(data, sortById, desc) {
+    return data.sort((row1, row2) => {
+      const rows = desc ? [row2, row1] : [row1, row2];
+      const firstVal = rows[0][sortById];
+      const secondVal = rows[1][sortById];
+      if (typeof firstVal === 'string' && typeof secondVal === 'string') {
+        return secondVal.localeCompare(firstVal);
+      }
+      if (typeof firstVal === 'undefined' || firstVal === null) {
+        return 1;
+      }
+      return -1;
+    });
+  }
+
   isEqualish(val1, val2) {
     return isEqual(alterForComparison(val1), alterForComparison(val2));
   }
 
-  formatValue(value, key) {
+  formatValue(value, key, controlsMap = this.state.controlsMap) {

Review comment:
       It looks like you can remove state from the default value now? Looks 
like you always have something to pass in. 




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

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