int _compareNaturally()

in lib/src/comparators.dart [258:275]


int _compareNaturally(String a, String b, int index, int aChar, int bChar) {
  assert(aChar != bChar);
  var aIsDigit = _isDigit(aChar);
  var bIsDigit = _isDigit(bChar);
  if (aIsDigit) {
    if (bIsDigit) {
      return _compareNumerically(a, b, aChar, bChar, index);
    } else if (index > 0 && _isDigit(a.codeUnitAt(index - 1))) {
      // aChar is the continuation of a longer number.
      return 1;
    }
  } else if (bIsDigit && index > 0 && _isDigit(b.codeUnitAt(index - 1))) {
    // bChar is the continuation of a longer number.
    return -1;
  }
  // Characters are both non-digits, or not continuation of earlier number.
  return (aChar - bChar).sign;
}