def _FixProvidesOrRequires(self, tokens):
    strings = self._GetRequireOrProvideTokenStrings(tokens)
    sorted_strings = sorted(strings)

    # Make a separate pass to remove any blank lines between goog.require/
    # goog.provide tokens.
    first_token = tokens[0]
    last_token = tokens[-1]
    i = last_token
    while i != first_token and i is not None:
      if i.type is Type.BLANK_LINE:
        tokenutil.DeleteToken(i)
      i = i.previous

    # A map from required/provided object name to tokens that make up the line
    # it was on, including any comments immediately before it or after it on the
    # same line.
    tokens_map = self._GetTokensMap(tokens)

    # Iterate over the map removing all tokens.
    for name in tokens_map:
      tokens_to_delete = tokens_map[name]
      for i in tokens_to_delete:
        tokenutil.DeleteToken(i)

    # Save token to rest of file. Sorted token will be inserted before this.
    rest_of_file = tokens_map[strings[-1]][-1].next

    # Re-add all tokens in the map in alphabetical order.
    insert_after = tokens[0].previous
    for string in sorted_strings:
      for i in tokens_map[string]:
        if rest_of_file:
          tokenutil.InsertTokenBefore(i, rest_of_file)
        else:
          tokenutil.InsertTokenAfter(i, insert_after)
          insert_after = i
Sorts goog.provide or goog.require statements.
dataset/ETHPy150Open google/closure-linter/closure_linter/requireprovidesorter.py/RequireProvideSorter._FixProvidesOrRequires