I have an ArrayList, mBuyLimits. Each item on mBuyLimits is an
instance of class "LongTermLimitOnBuy" as defined below:
public class LongTermLimitOnBuy : LongTermLimit, IComparable
{
public LongTermLimitOnBuy(double price, int shares) : base
(price, shares)
{
}
// Sort by Price in descending order
public int CompareTo(object other)
{
LongTermLimitOnBuy lb = (LongTermLimitOnBuy)other;
if (this.Price >= lb.Price)
{
return 1;
}
else
{
return 0;
}
}
}
However, after I execute the following:
mBuyLimits.Sort();
The items on mBuyLimits are not sorted by Price in descending order.
They appear to be in random order. How come they are not sorted?


