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.