code: function getSortedColumns(tableStructure, sortColumn, compareFunction) {
    // With help from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
    var mappedArray = sortColumn.julianDatesOrValues.map(function(value, i) {
      return { index: i, value: value };
    });
    if (!defined(compareFunction)) {
      if (sortColumn.type === VarType.TIME) {
        compareFunction = function(a, b) {
          if (defined(a) && defined(b)) {
            return JulianDate.compare(a, b);
          }
          return defined(a) ? -1 : defined(b) ? 1 : 0; // so that undefined > defined, ie. all undefined dates go to the end.
        };
      } else {
        compareFunction = function(a, b) {
          return +(a > b) || +(a === b) - 1;
        };
      }
    }
    mappedArray.sort(function(a, b) {
      return compareFunction(a.value, b.value);
    });
    return tableStructure.columns.map(column => {
      var sortedValues = mappedArray.map(element => column.values[element.index]);
      return new TableColumn(column.name, sortedValues, column.getFullOptions());
    });
  }
docs: Returns new columns sorted in sortColumn order.