I need to sort Wrapper List by two values(Quantity and Price)
. The below code Sorts List only by Quantity.How to sort list by both Quantity and Price
.
public Class SortByTwoValues implements Comparable
{
public Decimal Quantity{get; set;}
public Decimal Price{get; set;}
public String ItemName{get;set;}
public Integer compareTo(Object compareTo)
{
SortByTwoValues compareToRec = (SortByTwoValues)compareTo;
if (Quantity == compareToRec.Quantity)
return 0;
if (Quantity > compareToRec.Quantity)
return 1;
return -1;
}
}
Thanks in advance