code: def hilbert_sort(x):
      
      d = 1 if x.ndim == 1 else x.shape[1]
      if d == 1:
          return np.argsort(x, axis=0)
      xs = invlogit((x - np.mean(x, axis=0)) / np.std(x, axis=0))
      maxint = np.floor(2**(62 / d))
      xint = np.floor(xs * maxint).astype('int')
      return np.argsort(hilbert_array(xint))
docs: Hilbert sort: sort vectors according to their Hilbert index. 
      
      Parameters
      ----------
      x : (N,) or (N, d) float numpy.ndarray
          N vectors in R^d
  
      Returns
      -------
      A : (N,) int numpy.ndarray
          argsort (e.g. x[A[0], :] is the vector with smallest H index). 
  
      Note
      ----
      The vectors in `x` are first (a) standardized; and (b) applied a logistic
      transformation so as to lie in [0,1]^d.