// http://www.programcreek.com/2013/01/sort-linkedlist-of-user-defined-objects-in-java/
public class House implements Comparable<House> {
    String type;
    int size;
    public House(String t, int s) {
        type = t;
        size = s;
    }
    public int manualyCompareTo(House o) {
        int comparedSize = o.size;
        if (this.size > comparedSize) {
            return 1;
        } else if (this.size == comparedSize) {
            return 0;
        } else {
            return -1;
        }
    }
    // No te lies. Esta es mi version :-)
    @Override
    public int compareTo(House other) {
        return Integer.compare(size, other.size);
    }
    // Y si no sabiais que existia public static int Integer.compare(int x, int y)
    public int equivalenteCompareTo(House other) {
        Integer mySize = size;
        return mySize.compareTo(other.size);
        /*
        return size.compareTo(other.size);
        ERR: int cannot be deferenced
        */
    }
    @Override
    public boolean equals(Object obj) {
        // Version pro
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final House other = (House) obj;
        return (this.size == other.size);
    }
    // A class that overrides equals must also override hashCode.
    // Puede que no los distribuya uniformemente,
    // pero al menos es coherente con los dos anteriores.
    @Override
    public int hashCode() {
        return Integer.hashCode(size);
    }    
    @Override
    public String toString() {
        return type;
    }
}
