Would it make sense for this routine to exist in the main distarray stuff (ie. not in the plotting part)?
It seems like it is meaningful outside the context of plotting the rank distribution.

Also: If `arr` is a floating point array, will the returned array also be floating point? I imagine that the result should always be an integer array. (Even though none of the current examples use floating point arrays.)