I would like to sort an array of objects by their distance. The problem is that the distance value is a floating point and IComparer only will accept an integer as a return value.
class SortDistanceAscending : IComparer<ObjectDistance>
{
static IComparer<ObjectDistance> comparer = new SortDistanceAscending();
public int Compare(ObjectDistance a, ObjectDistance b)
{
return a.Distance - b.Distance;
}
public static IComparer<ObjectDistance> Comparer
{
get { return comparer; }
}
}
How can I keep the accuracy of comparing two floats in this case?