def enum_matrix(arr, axis=0, indices=[], field_name='i'):
    """
    Takes a 1-dimensional or 2-dimensional array and returns a sorted
    structured array with indices.

    :param arr: 1-dimensional or 2-dimensional numpy array.
    :type arr: array
    
    :param axis: Array axis 0 or 1. Default is 0.
    :type axis: int, optional
    
    :param indices: List of indices. If 'indices' is empty, then `indices` 
        is set to a range of indices for the length of `arr`. 
        Default is an empty list.
    :type indices: list, optional
    
    :param field_name: Name for indices in the structured array dtype. 
        Default is 'i'.
    :type field_name: string, optional

    :returns: mt : A sorted structured array with indices.

    :See Also: :meth:`zip_arr`

    **Examples**

    >>> arr = np.array([[6,3,7],[2,0,4]])
    >>> enum_matrix(arr)
    array([[(2, 7), (0, 6), (1, 3)],
           [(2, 4), (0, 2), (1, 0)]], 
           dtype=[('i', '<i8'), ('value', '<i8')])
    """
    #if len(indices) == 0:
    #    indices = np.arange(arr.shape[1])
    if len(indices) == 0 and len(arr.shape) > 1:
        indices = np.arange(arr.shape[1])
    
    if type(indices) == list:
        indices = np.array(indices)
    ind = np.array([indices.copy() for i in xrange(arr.shape[0])])
    dt = [(field_name, indices.dtype), ('value', arr.dtype)]
    mt = zip_arr(ind, arr, field_names=[field_name, 'value'])

    if 1 > len(arr.shape):
        if axis:
            for i in xrange(arr.shape[axis]):
                idx = np.argsort(mt['value'][:,i])
                mt[field_name][:,i] = ind[:,i][idx]
                mt['value'][:,i] = arr[:,i][idx]
                mt[:,i] = mt[:,i][::-1]	
        else:
            for i in xrange(arr.shape[axis]):
                idx = np.argsort(mt['value'][i])
                mt[field_name][i] = ind[i][idx]
                mt['value'][i] = arr[i][idx]
                mt[i,:] = mt[i,:][::-1]
    else:
        idx = np.argsort(arr)
        mt[field_name][:] = idx[:]
        mt['value'][:] = arr[idx]

    return mt
dataset/ETHPy150Open inpho/vsm/vsm/structarr.py/enum_matrix/swapped operands of `>`