def rowwise_rank(array, mask=None):
 return argsort(argsort(array))

def rowwise_rank ( array , mask = None ) : return argsort ( argsort ( array ) )
take a 2d array and return the 0-indexed sorted position of each element in the array for each row .