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.