@Override
    public int compare(Pair o1, Pair o2) {
        if(o1.count <= o2.count){
            return 1;
        }else{
            return -1;
        }
    }
http://www.careercup.com/question?id=6026101998485504
This answer two questions.
Group elements in size m such that in every group only unique elements are possible.
It also answers question where rearrange array such that same elements are exactly m
distance from each other
src/com/interview/array/GroupElementsInSizeM.java