public int compareTo(pair other) {
            // TODO Auto-generated method stub
            if (val != other.val) {
                return val - other.val;
            } else {
                return id - other.id;
            }
        }