took me a few months to figure this out (jeez im dumb) but by changing the less than sign to greater than in top 5, the list can be sorted in descending order :)
This commit is contained in:
parent
4b2cfdc89b
commit
6db1cebae8
@ -30,9 +30,9 @@ def bubble():
|
|||||||
def top5():
|
def top5():
|
||||||
for i in range(len(marks)):
|
for i in range(len(marks)):
|
||||||
for j in range(0, len(marks)-i-1):
|
for j in range(0, len(marks)-i-1):
|
||||||
if marks[j]>marks[j+1]:
|
if marks[j]<marks[j+1]:
|
||||||
marks[j], marks[j+1] = marks[j+1], marks[j]
|
marks[j], marks[j+1] = marks[j+1], marks[j]
|
||||||
print("Top 5 marks using bubble sorting:\t", marks[len(marks):len(marks)-6:-1]) # Requires 6 elements in the list.
|
print("Top 5 marks using bubble sorting:\t", marks[0:5])
|
||||||
|
|
||||||
|
|
||||||
def choose_optn():
|
def choose_optn():
|
||||||
|
Loading…
Reference in New Issue
Block a user