Well done!

You have completed Comparator!

Quiz Question 1 of 1

Assume that you have a class representing Planet. It has a method named getDistanceInAstromicalUnits that helps figure out the distance from the Sun.

Instances of the Planet class are created and placed in an Planet[] array named planets.

Which code snippet would allow you to sort the planets array by distance?

Choose the correct answer below:

Skip Quiz Review Video