How big is the dataset going to be? If it is tiny then you could use skew(1) or something. If not we need to rethink this approach; in a sort all the records with identical values end up on the same node.