Sort tuples using lambda as key Dry Run in PYTHON

Sort tuples using lambda as key is an interactive PYTHON dry run visualizer from the Special programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

Sort tuples using lambda as key Program Code

students = [("Alice", 22, 85), ("Bob", 19, 92), ("Charlie", 21, 78)]
by_age = sorted(students, key=lambda x: x[1])
by_score = sorted(students, key=lambda x: x[2], reverse=True)

print("By age:", by_age)
print("By score:", by_score)

View the complete Special programs page.

Program Console Sort tuples using lambda as key Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.