function lexicographicalComparator(a, b) {
  const splitA = splitString(a);
  const splitB = splitString(b);

  for (var i = 0; i < splitA.length && i < splitB.length; i++) {
    const aPart = splitA[i];
    const bPart = splitB[i];

    if (aPart.str == bPart.str)
      continue;

    if (aPart.isNumber && bPart.isNumber) {
      const aNumber = Number(aPart.str);
      const bNumber = Number(bPart.str);

      return aNumber - bNumber;
    }

    // Not numbers
    return localeComparator(aPart, bPart);
  }

  return splitA.length - splitB.length;
}
/*
 * This comparator compares two strings by splitting each string into words.
 * Pairs of words are then compared as strings or numbers.
 */
This comparator compares two strings by splitting each string into words.
Pairs of words are then compared as strings or numbers.
This comparator compares two strings by splitting each string into words . Pairs of words are then compared as strings or numbers .
function lexicographicalComparator(a, b) {
  const splitA = splitString(a);
  const splitB = splitString(b);
  for (var i = 0; i < splitA.length && i < splitB.length; i++) {
    const aPart = splitA[i];
    const bPart = splitB[i];
    if (aPart.str == bPart.str)
      continue;
    if (aPart.isNumber && bPart.isNumber) {
      const aNumber = Number(aPart.str);
      const bNumber = Number(bPart.str);
      return aNumber - bNumber;
    }
    return localeComparator(aPart, bPart);
  }
  return splitA.length - splitB.length;
}
function lexicographicalComparator ( a , b ) { const splitA = splitString ( a ) ; const splitB = splitString ( b ) ; for ( var i = 0 ; i < splitA . length && i < splitB . length ; i ++ ) { const aPart = splitA [ i ] ; const bPart = splitB [ i ] ; if ( aPart . str == bPart . str ) continue ; if ( aPart . isNumber && bPart . isNumber ) { const aNumber = Number ( aPart . str ) ; const bNumber = Number ( bPart . str ) ; return aNumber - bNumber ; } return localeComparator ( aPart , bPart ) ; } return splitA . length - splitB . length ; }
This comparator compares two strings by splitting each string into words.
This comparator compares two strings by splitting each string into words .
// Not numbers