Tag Archive: collection

Jan
26

Java Sorting Objects at Runtime using Comparator

Java gives very convenient way for sorting collection types by Collections.sort method. It have two flavors Collections.sort( collection, new Comparator < T>( )){} This is runtime sorting, & you will create an anonymous class implementation and will override Comparator’s compare method and return value -1, 0 , 1. Collections.sort( collection) You provide collection whose objects implemented Comparable or Comparator interface …

Continue reading »

Permanent link to this article: http://www.javaplex.com/blog/java-sorting-objects-at-runtime-using-comparator/