package Util;

import java.util.Comparator;

import djondb.BSONObj;

public class ReceiptStringComparator implements Comparator<BSONObj>{

	private String _order;
	private String _field;
	public ReceiptStringComparator(final String order, final String field)
	{
		_order = order;
		_field = field;
	}
	@Override
	public int compare(BSONObj o1, BSONObj o2) {
		// TODO Auto-generated method stub
		String n1 = o1.getString(_field);
		String n2 = o2.getString(_field);
		if(_order.equalsIgnoreCase("asc"))
		{
			return n1.compareToIgnoreCase(n2);
		}
		else
		{
			return n2.compareToIgnoreCase(n1);
		}
	}

}
