static/js/datable.js
/**
 * Sort data table by one column.
 * @function sortDataTable
 * @param {Object} mo - main object
 * @param {number} idx - column index
 * @param {boolean} order - ascending (false) or descending (true)
 * @description It uses a trick to sort one array based on another array.
 * Only works with numeric columns. Won't work if there are NaN values.
 */
Sort data table by one column.
Sort data table by one column .
function sortDataTable(mo, idx, order) {
  const tabled = mo.tabled;
  const col = mo.data[idx];
  if (order) { 
    tabled.sort((a, b) => { return col[b] - col[a]; });
  } else { 
    tabled.sort((a, b) => { return col[a] - col[b]; });
  }
}
function sortDataTable ( mo , idx , order ) { const tabled = mo . tabled ; const col = mo . data [ idx ] ; if ( order ) { tabled . sort ( ( a , b ) => { return col [ b ] - col [ a ] ; } ) ; } else { tabled . sort ( ( a , b ) => { return col [ a ] - col [ b ] ; } ) ; } }
Sort data table by one column.
Sort data table by one column .
// descending // ascending