export function compareTagNames()

in frontend/app/common/classes/sorting.ts [52:91]


export function compareTagNames(a: string, b: string): number {
  let ai = 0;
  let bi = 0;
  while (true) {
    if (ai === a.length) {
      return bi === b.length ? 0 : -1;
    }
    if (bi === b.length) {
      return 1;
    }
    if (isDigit(a[ai]) && isDigit(b[bi])) {
      const ais = ai;
      const bis = bi;
      ai = consumeNumber(a, ai + 1);
      bi = consumeNumber(b, bi + 1);
      const an = parseFloat(a.slice(ais, ai));
      const bn = parseFloat(b.slice(bis, bi));
      if (an < bn) {
        return -1;
      }
      if (an > bn) {
        return 1;
      }
      continue;
    }
    if (isBreak(a[ai])) {
      if (!isBreak(b[bi])) {
        return -1;
      }
    } else if (isBreak(b[bi])) {
      return 1;
    } else if (a[ai] < b[bi]) {
      return -1;
    } else if (a[ai] > b[bi]) {
      return 1;
    }
    ai++;
    bi++;
  }
}