for reference see 3.4 in http://unicode.org/reports/tr9/
function _invertByLevel(level, charArray, sourceToTargetMap, levels, params) {
      if (params.hiLevel < level) {
        return;
      }

      if (level === 1 && _dir === DIR_RTL && !_hasUbatB) {
        charArray.reverse();
        sourceToTargetMap && sourceToTargetMap.reverse();
        return;
      }

      var ch,
          high,
          end,
          low,
          len = charArray.length,
          start = 0;

      while (start < len) {
        if (levels[start] >= level) {
          end = start + 1;

          while (end < len && levels[end] >= level) {
            end++;
          }

          for (low = start, high = end - 1; low < high; low++, high--) {
            ch = charArray[low];
            charArray[low] = charArray[high];
            charArray[high] = ch;

            if (sourceToTargetMap) {
              ch = sourceToTargetMap[low];
              sourceToTargetMap[low] = sourceToTargetMap[high];
              sourceToTargetMap[high] = ch;
            }
          }

          start = end;
        }

        start++;
      }
    }