Lesson 33 of 34

Sorting, Comparators మరియు Lambdas

10 min 35 XP

Collections.sort() సంఖ్యలు, Strings ను sort చేస్తుంది. Objects ను sort చేయడానికి Comparator కావాలి. (a, b) -> ... వంటి lambda ఒక చిన్న method ను ఒకే లైన్‌లో రాస్తుంది.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Streams తో collections ను కొన్ని పదాల్లోనే filter, transform చేయవచ్చు. ఆధునిక Java interviews లో వీటి గురించి తరచుగా అడుగుతారు.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

Challenge

+35 XP

n చదవండి, తర్వాత name, score ఉన్న n లైన్లు. score ప్రకారం, ఎక్కువది ముందుగా print చేయండి; score సమానమైతే name ప్రకారం A నుండి Z. Input: 3 Ram 80 Asha 95 Bala 80 Output: Asha 95 Bala 80 Ram 80

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.