function sortLevelOfTree(array, { [COLUMN_SORT_ORDER]: sortOrder } = {}) {
  if (sortOrder == null) {
    // don't sort unless there's a column sort order set
    return;
  }
  array.sort((a, b) => {
    if (a.value === b.value) {
      return 0;
    }
    // by default use "<" to compare values
    let result = a.value < b.value ? -1 : 1;
    // strings should use localeCompare to handle accents, etc
    if (typeof a.value === "string") {
      result = a.value.localeCompare(b.value);
    }
    // flip the comparison for descending
    if (sortOrder === COLUMN_SORT_ORDER_DESC) {
      result *= -1;
    }
    return result;
  });
}
// Sorts the array of nodes in place if a sort order is set for that column
Sorts the array of nodes in place if a sort order is set for that column
Sorts the array of nodes in place if a sort order is set for that column
function sortLevelOfTree(array, { [COLUMN_SORT_ORDER]: sortOrder } = {}) {
  if (sortOrder == null) {
    return;
  }
  array.sort((a, b) => {
    if (a.value === b.value) {
      return 0;
    }
    let result = a.value < b.value ? -1 : 1;
    if (typeof a.value === "string") {
      result = a.value.localeCompare(b.value);
    }
    if (sortOrder === COLUMN_SORT_ORDER_DESC) {
      result *= -1;
    }
    return result;
  });
}
function sortLevelOfTree ( array , { [ COLUMN_SORT_ORDER ] : sortOrder } = { } ) { if ( sortOrder == null ) { return ; } array . sort ( ( a , b ) => { if ( a . value === b . value ) { return 0 ; } let result = a . value < b . value ? - 1 : 1 ; if ( typeof a . value === "string" ) { result = a . value . localeCompare ( b . value ) ; } if ( sortOrder === COLUMN_SORT_ORDER_DESC ) { result *= - 1 ; } return result ; } ) ; }
Sorts the array of nodes in place if a sort order is set for that column
Sorts the array of nodes in place if a sort order is set for that column
// don't sort unless there's a column sort order set // by default use "<" to compare values // strings should use localeCompare to handle accents, etc // flip the comparison for descending