packages/solver/lib/simplifyExpression/collectAndCombineSearch/LikeTermCollector.js
function sortTerms(a, b) {
  if (a === b) {
    return 0;
  }
  // if no exponent, sort alphabetically
  if (a.indexOf('^') === -1) {
    return a < b ? -1 : 1;
  }
  // if exponent: sort by symbol, but then exponent decreasing
  else {
    const symbA = a.split('^')[0];
    const expA = a.split('^')[1];
    const symbB = b.split('^')[0];
    const expB = b.split('^')[1];
    if (symbA !== symbB) {
      return symbA < symbB ? -1 : 1;
    }
    else {
      return expA > expB ? -1 : 1;
    }
  }
}
function sortTerms(a, b) {
  if (a === b) {
    return 0;
  }
  // if no exponent, sort alphabetically
  if (a.indexOf('^') === -1) {
    return a < b ? -1 : 1;
  }
  // if exponent: sort by symbol, but then exponent decreasing
  else {
    const symbA = a.split('^')[0];
    const expA = a.split('^')[1];
    const symbB = b.split('^')[0];
    const expB = b.split('^')[1];
    if (symbA !== symbB) {
      return symbA < symbB ? -1 : 1;
    }
    else {
      return expA > expB ? -1 : 1;
    }
  }
}
function sortTerms ( a , b ) { if ( a === b ) { return 0 ; } // if no exponent, sort alphabetically if ( a . indexOf ( '^' ) === - 1 ) { return a < b ? - 1 : 1 ; } // if exponent: sort by symbol, but then exponent decreasing else { const symbA = a . split ( '^' ) [ 0 ] ; const expA = a . split ( '^' ) [ 1 ] ; const symbB = b . split ( '^' ) [ 0 ] ; const expB = b . split ( '^' ) [ 1 ] ; if ( symbA !== symbB ) { return symbA < symbB ? - 1 : 1 ; } else { return expA > expB ? - 1 : 1 ; } } }
Sort function for termnames. Sort first by symbol name, and then by exponent.
Sort function for termnames . Sort first by symbol name and then by exponent .