Sort list in descending order Dry Run in PYTHON

Sort list in descending order is an interactive PYTHON dry run visualizer from the Lists 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 list in descending order Program Code

# Sort list in descending order
nums = [3, 7, 1, 9, 4, 6, 2, 8]
print("Original:", nums)

# Method 1: sort(reverse=True)
nums.sort(reverse=True)
print("After sort(reverse=True):", nums)

# Method 2: sorted() with reverse
nums2 = [3, 7, 1, 9, 4, 6, 2, 8]
desc = sorted(nums2, reverse=True)
print("Using sorted(..., reverse=True):", desc)

View the complete Lists programs page.

Program Console Sort list in descending order Topic: PYTHON Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.