Hey everyone,
I am having a small problem with sorting objects.
I have a method called organizeTank. It should sort the fish in the tank such that: (1) all dead fish come first sorted according to size in descending order, (2) all live fish come next such that herbivores come first sorted according to size in descending order and carnivores come next sorted according to speed in ascending order.
{specie, size, speed, type, condition}
fish[0] = {"shark", 3, 7, "herbivore", true};
fish[1] = {"cat fish", 6, 10, "herbivore", false};
fish[2] = {"gold fish", 5, 7, "herbivore", true};
fish[3] = {"cat fish", 10, 8, "carnivore", true};
fish[4] = {"shark", 6, 10, "herbivore", true};
fish[5] = {"gold fish", 1, 4, "herbivore", false};
fish[6] = {"cat fish", 2, 6, "herbivore", false};
I will have to sort these objects according to the instructions, how do I that using selection sorting?
Thanks for your help!