Changed sorting of ArrayList so it is compatible with Java 7 instead of
just Java 8.