input: def rearrange_on_third(l: list):
      """This function accepts a list l and returns a new list where
      the elements at indices not divisible by three remain unchanged, while the elements at indices divisible by three
      are sorted relative to those positions.
      >>> rearrange_on_third([1, 2, 3])
      [1, 2, 3]
      >>> rearrange_on_third([5, 6, 3, 4, 8, 9, 2])
      [2, 6, 3, 4, 8, 9, 5]
      """
output:     def rearrange_on_third(l: list):
      indices_div_by_three = [i for i in range(len(l)) if i % 3 == 0]
      elements_to_sort = sorted([l[i] for i in indices_div_by_three])
      
      new_list = l[:]
      for index, sorted_value in zip(indices_div_by_three, elements_to_sort):
          new_list[index] = sorted_value
      
      return new_list