Theory on how to best compare objects.
I'm soliciting thoughts on how best to approach this:
I have four objects with a .speed property. I want to compare all four and snag the object with the lowest speed. That alone I can get a grip on no problem. But, it's quite possible that 2 or more of the objects could have the same lowest speed. Here's where my ideas start to get muddled and rather involved. I'm hoping someone might help me cut through the fog and point me in the general direction of how I should be approaching this.
Here's my general thought at this point...
Compare two, toss the lowest in an array, if equal toss them both in.
Compare the third to the array, if it's lower replace the existing item(s) with this one, if it's equal add it.
Do a similiar thing with the fourth.
To do all that I can't think of anything but a boatload of IFs and nested IFs.
Does anyone have any other/better thoughts?