Lesson 21 of 24

Lambdas மற்றும் Custom SortingLambdas and Custom Sorting

10 min 35 XP

Lambda என்பது பெயரில்லாத சிறிய function: [capture](params) { body }. sort, count_if, for_each போன்றவற்றுக்கு நம் விதியைக் கொடுக்க மிகவும் பயனுள்ளது.

A lambda is a small unnamed function: [capture](params) { body }. It's perfect for handing your own rule to sort, count_if or for_each.

Example: edit me and press Run

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

Challenge

+35 XP

n மற்றும் n சொற்களைப் படித்து, நீளம் குறைந்தது முதலில்; நீளம் சமம் என்றால் அகர வரிசையில் என்று வரிசைப்படுத்தி ஒவ்வொன்றையும் தனி வரியில் print செய்யுங்கள். Input: 5 banana kiwi apple fig cherry Output: fig kiwi apple banana cherry

Read n and n words. Sort them by length (shortest first), breaking ties alphabetically, and print one per line. Input: 5 banana kiwi apple fig cherry Output: fig kiwi apple banana cherry

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