code: def extend(self, values):
          
          _maxes, _keys, _lists, _load = self._maxes, self._keys, self._lists, self._load
  
          if not isinstance(values, list):
              values = list(values)
  
          keys = list(map(self._key, values))
  
          if any(keys[pos - 1] > keys[pos]
                 for pos in range(1, len(keys))):
              raise ValueError('given sequence not in sort order')
  
          offset = 0
  
          if _maxes:
              if keys[0] < _keys[-1][-1]:
                  msg = '{0} not in sort order at index {1}'.format(repr(values[0]), self._len)
                  raise ValueError(msg)
  
              if len(_keys[-1]) < self._half:
                  _lists[-1].extend(values[:_load])
                  _keys[-1].extend(keys[:_load])
                  _maxes[-1] = _keys[-1][-1]
                  offset = _load
  
          len_keys = len(_keys)
  
          for idx in range(offset, len(keys), _load):
              _lists.append(values[idx:(idx + _load)])
              _keys.append(keys[idx:(idx + _load)])
              _maxes.append(_keys[-1][-1])
  
          _index = self._index
  
          if len_keys == len(_keys):
              len_index = len(_index)
              if len_index > 0:
                  len_values = len(values)
                  child = len_index - 1
                  while child:
                      _index[child] += len_values
                      child = (child - 1) >> 1
                  _index[0] += len_values
          else:
              del _index[:]
  
          self._len += len(values)
docs: Extend the list by appending all elements from the *values*. Raises a
          ValueError if the sort order would be violated.