is not an efficient way i think because
We need to define efficiency here.
Data Saved in the ArrayList is String data type.
Which is the case regardless of whether you use Comparable or not.
If we want to use Comparable , Comparator interface we need to create Class for that
The memory overhead of an extra class is negligible and can be safely ignored.
Resource Usage will go high if the size of the List Increase than the Karol Koranecki Coding
How did you conclude this without knowing how a Comparable implementation sorts its elements ?
The Comparable and Comparator implementations define clear contracts that code should follow. I would expect a candidate to choose an existing solution / design over writing something anew. This is especially true with this scenario. You cannot use Comparable with Strings. Strings already have a natural ordering defined by Comparable. Comparator is a good answer, unless there was a requirement explicitly asking you not to use a Comparator.