Inference for Ranks with Applications to Mobility Across Neighborhoods and Academic Achievement Across Countries