replaced Integer.compare(int x, int y) with Java 1.6 compatible version