Implement this method to have a valid class that implements the IComparer Interface.
The implemented method should return:
-1 if object a < object b
1 if object a > object b
0 if object a = object b
So what needs to be done is
if(object a < object b) then
return -1
elseif(object a > object b) then
return 1
else
return 0
end if
How you evaluate which object is bigger is up to you and depends entierly on what kind of objects you are comparing and what you want to acomplish. To compare the objects you will need to typecast the objects to their actual types.
Speed optimizations for sorting:
If you know you will only be doing ascending sort then you can speed optimize the comparer method by only evaluating to -1 and 0 like:
if(object a < object b) then
return -1
else
return 0
Same thing goes for if you know you will only be doing descending sort then you can speed optimize the comparer method by only evaluating to 1 and 0 like:
if(object a > object b) then
return 1
else
return 0