Archive for the ‘java’ Category

First In First Out Comparator

May 23, 2007

Here is a simple first in first out comparator I recently used.

You can use this to preserve the order of elements getting added to a SortedMap or SortedSet.

public class FIFOComparator implements java.util.Comparator

public int compare(Object arg0, Object arg1) {
return 1;


For more information on Comparators check out this URL –