Fixing comparison of Double values

`(int)(double1 - double2)` is not the right way to write a comparator for doubles. It fails when the absolute difference between `double1` and `double2` is less than 1. [Double.compare(double, double)](http://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#compare(double, double)) is a better choice.