WeCodeAcademy

Sorting and Lambda Functions

sorted returns a new sorted list. The key argument says what to sort by, often with a small one-line lambda function.

Examplepython
Open in editor »
Quick check

What does `key=len` sort by?

Your turn: write the code

Sort words by length, shortest first, and print the result.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.