code: def rank(self, value):
          
          i = 0
          n = len(self._tree)
          rank = 0
          count = 0
          while i < n:
              cur = self._tree[i]
              if value < cur:
                  i = 2 * i + 1
                  continue
              elif value > cur:
                  rank += self._counts[i]
                  # subtract off the right tree if exists
                  nexti = 2 * i + 2
                  if nexti < n:
                      rank -= self._counts[nexti]
                      i = nexti
                      continue
                  else:
                      return (rank, count)
              else:  # value == cur
                  count = self._counts[i]
                  lefti = 2 * i + 1
                  if lefti < n:
                      nleft = self._counts[lefti]
                      count -= nleft
                      rank += nleft
                      righti = lefti + 1
                      if righti < n:
                          count -= self._counts[righti]
                  return (rank, count)
          return (rank, count)
docs: Returns the rank and count of the value in the btree.