Concept Flow - Sorted and custom comparators
Start with array
Call sorted()
Check if custom comparator provided?
No→Use default ascending order
Yes
Use custom comparator to compare elements
Sort elements accordingly
Return sorted array
End
The array is sorted by calling sorted(). If a custom comparator is given, it compares elements using that; otherwise, it sorts in ascending order.