Changed sort method to JDK 7 compatibility