Lesson 21 of 24

Lambdas और Custom Sorting

10 min 35 XP

Lambda एक छोटा बिना नाम का function है: [capture](params) { body }। sort, count_if या 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 शब्द पढ़ें। उन्हें लंबाई के अनुसार (सबसे छोटा पहले) sort करें, बराबरी पर वर्णमाला क्रम से, और हर लाइन पर एक print करें। 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.