docs: function getRankingFnForIndices(idx1, idx2) {
    return function(a, b) {
      /*
       * If there is a valid idx2:
       * check if the value at idx1 for 'a' and 'b' is a valid value
       * and not some falsy value.
       * If it is falsy, make it an empty string. This is done because
       * if we try to index on a falsy value (e.g., a[idx1] = null, a[idx1][idx2] will throw)
       * then it will throw as we can't index on something that isn't present.
       * If we set it to an empty string (or empty array or empty object) then indexing on it
       * wont throw, but will return undefined cuz strings can have properties as they're objects too
       * Because you know, JS and its strings 乁( ◔ ౪◔)ㄏ
       * This undefined, when received by getIndicesOfCaptures, it will return undefined too.
       * This undefined when given to getRank, it will return -9999999.
       * Hence, all falsy values will get the same rank and won't be moved.
       */
      if (idx2 || idx2 === 0) {
        if (!a[idx1]) a[idx1] = '';
        if (!b[idx1]) b[idx1] = '';
      }
      var aIndices = idx2 || idx2 === 0 ? getIndicesOfCaptures(a[idx1][idx2], a[idx1]) : getIndicesOfCaptures(a[idx1], a);
      var bIndices = idx2 || idx2 === 0 ? getIndicesOfCaptures(b[idx1][idx2], b[idx1]) : getIndicesOfCaptures(b[idx1], b);
      var aRank = getRank(aIndices);
      var bRank = getRank(bIndices);
  
      //rank higher? put el before
      if (aRank > bRank) return -1;
      //rank lower? put el after
      else if (aRank < bRank) return 1;
      //ranks equal?
      //The matched string with first match closer to beginning of source string ranks higher
      //ie., the smaller the index of the first capture group the higher it ranks
      else {
        if (aIndices[1] < bIndices[1]) return -1;
        else if (aIndices[1] > bIndices[1]) return 1;
        //ranks still equal? The smaller string ranks higher
        else {
          var aLen = idx2 || idx2 === 0 ? a[idx1][idx2].length : a[idx1].length;
          var bLen = idx2 || idx2 === 0 ? b[idx1][idx2].length : b[idx1].length;
  
          //an element can have rank 0 only if the indices array for it contained only zeroes
          //that can happen only when the regex used was for searchString === ''
          //which means empty searchString was given to index#search
          //So just return 0 i.e., don't change the order of elements
          //and keep em as is
          if (aRank === 0 && bRank === 0) return 0;
          if (aLen < bLen) return -1;
          if (aLen > bLen) return 1;
          return 0;
        }
      }
    };
  }