function mergeSortByTabIndex(left, right) {
  /** @type {HTMLElement[]} */
  const result = [];
  while (left.length > 0 && right.length > 0) {
    if (hasLowerTabOrder(left[0], right[0])) {
      result.push(/** @type {HTMLElement} */ (right.shift()));
    } else {
      result.push(/** @type {HTMLElement} */ (left.shift()));
    }
  }

  return [...result, ...left, ...right];
}
@param {HTMLElement[]} left
@param {HTMLElement[]} right
@returns {HTMLElement[]}