Got it. Essentially the comment about the indices was spot on. Fixing it wasn't myrank(myrank()), but argsort(myrank()).