code: def arrayuniqify(X, retainorder=False):
      s = X.argsort()
      X = X[s]
      D = np.append([True],X[1:] != X[:-1])
      if retainorder:
          DD = np.append(D.nonzero()[0],len(X))
          ind = [min(s[x:DD[i+1]]) for (i,x) in enumerate(DD[:-1])]
          ind.sort()
          return ind
      else:
          return [D,s]