The runtime indicates the exception occurs when giving temp = keysit.next(). I thought this had been taken care of when I redefined keysit = keys.iterator() for the 2nd time, but maybe I'm missing the point. Any suggestions?
Map<Integer, Set<String>> lhm = new LinkedHashMap<Integer, Set<String>>();
public void sortMap() {
    Set<Integer> keys = hm.keySet();
    Iterator<Integer> keysit;
    int iterations = keys.size();
    int smallest;
    int temp;
    for(int i=0; i<iterations; i++) {
        keysit = keys.iterator();
        smallest = keysit.next();
        keysit = keys.iterator();  
        while(keysit.hasNext()) {
            temp = keysit.next();  
            if(temp<smallest) 
                smallest = temp;
            lhm.put(smallest, lhm.get(smallest));
            keys.remove(smallest);
        }
    }
    System.out.println(lhm);
}
 
     
    