Σ.Μ. Κεφ5 πιο συνοπτικός τρόπος 1ο πέρασμα

Επιλέξτε έναν πιο συνοπτικό τρόπο εκτέλεσης των παρακάτω εντολών, που δηλώνουν το πρώτο πέρασμα της αύξουσας ταξινόμησης σε μια λίστα 5 στοιχείων:

if students[4] < students[3]:

        students[4], students[3] = students[3], students[4]

if students[3] < students[2]:

        students[3], students[2] = students[2], students[3]

if students[2] < students[1]:

        students[2], students[1] = students[1], students[2]

if students[1] < students[0]:

        students[1], students[0] = students[0], students[1]

 

 

for j in range( 4, 0, -1):

        if studnets[j] < students[j-1]:

                students[j], students[j-1] = students[j-1], students[j]

for j in range( 4, 0, -1):

        if studnets[j-1] < students[j-2]:

                students[j-1], students[j-2] = students[j-2], students[j-1]

for j in range( 5, 0, -1):

        if studnets[j] < students[j-1]:

                students[j], students[j-1] = students[j-1], students[j]

for j in range( 4, -1, -1):

        if studnets[j] < students[j-1]:

                students[j], students[j-1] = students[j-1], students[j]