docstr: Applies a (potentially hierarchical) sort operation on a numpy array
  or pandas series/dataframe based on the grouping index or a
  user-supplied index.  Returns an object of the same type as the
  original data as well as the matching (sorted) Pandas index.
docstr_tok: ["Applies","a","(","potentially","hierarchical",")","sort","operation","on","a","numpy","array","or","pandas","series\/dataframe","based","on","the","grouping","index","or","a","user-supplied","index",".","Returns","an","object","of","the","same","type","as","the","original","data","as","well","as","the","matching","(","sorted",")","Pandas","index","."]
code: def sort(self, data, index=None):
      """Applies a (potentially hierarchical) sort operation on a numpy array
      or pandas series/dataframe based on the grouping index or a
      user-supplied index.  Returns an object of the same type as the
      original data as well as the matching (sorted) Pandas index.
      """
  
      if index is None:
          index = self.index
      if data_util._is_using_ndarray_type(data, None):
          if data.ndim == 1:
              out = pd.Series(data, index=index, copy=True)
              out = out.sort_index()
          else:
              out = pd.DataFrame(data, index=index)
              out = out.sort_index(inplace=False)  # copies
          return np.array(out), out.index
      elif data_util._is_using_pandas(data, None):
          out = data
          out = out.reindex(index)  # copies?
          out = out.sort_index()
          return out, out.index
      else:
          msg = (
              "data must be a Numpy array or a Pandas Series/DataFrame"
          )
          raise ValueError(msg)
  
imports: from statsmodels.compat.python import lrange, lzip
  import numpy
  import pandas
  import statsmodels.tools.data
  from pandas import Index, MultiIndex
label_desc: Use image node_id 10 for calling the Grouping obj's underlying member method code with example usage: obj.sort(data, index) and returns: np,  out, out,  out