I have a Shape class and in this class there is a method called getRepr() that can get a char representation of a shape. For example,
ShapeA.getRepr() ->'a'
ShapeB.getRepr() ->'b'
ShapeC.getRepr() ->'c'
Now I have an ArrayList that stores several shapes including ShapeE, ShapeA, ShapeD, ShapeC, and ShapeB.
The question is how can I use Collections.sort() to alphabetically rearrange these shapes in the ArrayList according to their char representations?
The expected result in this ArrayList after sorting should be ShapeA, ShapeB, ShapeC, ShapeD, ShapeE.
Or is there a way to reach this purpose without Collections.sort()?