code: function sortData(data, columnId, sortDirection, columns) {
    var column = getColumnById(columns, columnId);
  
    if (!column) {
      if (process.env.NODE_ENV !== 'production') {
        console.warn('No column found by ID', columnId, columns);
      }
  
      return data;
    }
  
    // read the type from `sortType` property if defined, otherwise use `type`
    var sortType = column.sortType == null ? column.type : column.sortType;
    var comparator = getSortComparator(sortType);
    var dataToSort = data.map(function (rowData, index) {
      return {
        rowData: rowData,
        index: index,
        sortValue: getSortValue(column, rowData, index, data, columns)
      };
    });
  
    // check if already sorted, and if so, just reverse
    var sortedData = void 0;
  
    // if already sorted in the opposite order, just reverse it
    if (alreadySorted(!sortDirection, dataToSort, comparator)) {
      sortedData = dataToSort.reverse();
  
      // if not sorted, stable sort it
    } else {
      sortedData = (0, _stable2.default)(dataToSort, comparator);
      if (sortDirection === _SortDirection2.default.Descending) {
        sortedData.reverse();
      }
    }
  
    sortedData = sortedData.map(function (sortItem) {
      return sortItem.rowData;
    });
  
    return sortedData;
  }
docs: Sorts the data based on sort value and column type. Uses a stable sort
  by keeping track of the original position to break ties unless the data
  is already sorted, in which case it just reverses the array.
  
  @param {Object[]} data the array of data for the whole table
  @param {String} columnId the column ID of the column to sort by
  @param {Boolean} sortDirection The direction to sort in
  @param {Object[]} columns The column definitions for the whole table
  @return {Object[]} The sorted data