Return the ranks of x along the first non-singleton dimension adjust for ties. If the optional argument dim is given, operate along this dimension.