Plz share the corrected code with approach

@Yuganshu Bro no need to follow the complex approach. Just use the anonymous class comparator approach. Here i am sharing mine for reference. The code is self explanatory, just check it out and lemme know if you have any doubt.