code: def _argsort_and_resolve_ties(time, random_state):
          n_samples = len(time)
          order = numpy.argsort(time, kind="mergesort")
          i = 0
          while i < n_samples - 1:
              inext = i + 1
              while inext < n_samples and time[order[i]] == time[order[inext]]:
                  inext += 1
              if i + 1 != inext:
                  random_state.shuffle(order[i:inext])
              i = inext
          return order