Put rows in order · in code: Sorting a List
Makes a sorted copy of a list: by one field of each row, like marks, or by the items themselves.
marks, biggest first.students.marks. Leave it empty for a list of plain numbers or words.5 for the top 5. Leave it empty to keep them all.Open it in the editor, press Run, then change it and run it again.
marks = [45, 80, 62, 30, 91]"Top 3: " + join(ranked)Top 3: 91, 80, 62marks = [45, 80, 62, 30, 91]ranked = sorted(marks, reverse=True)[:3]print("Top 3: " + ", ".join(str(item) for item in ranked))