'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.'

def sort(self, data, index=None):

    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)
        return (np.array(out), out.index)
    elif data_util._is_using_pandas(data, None):
        out = data
        out = out.reindex(index)
        out = out.sort_index()
        return (out, out.index)
    else:
        msg = 'data    must    be    a    Numpy    array    or    a    Pandas    Series/DataFrame'
        raise ValueError(msg)
