I am searching for a way to compare two adjacent items in a list, eg. comparing which has a higher value, and then I will sort them accordingly. It is a list the user will be inputting, so it is not a case of just
if l[1] > l[2]
, as I will not know the length of the list, so
I will need a general statement for use in a for loop.
I had the idea of having something akin to
for i in l:
if x > i[index of x + 1]
but do not know how to find the index of the variable.
Any help appreciated, Thank you
EDIT: I am aware of the built in sort function, but just wanted to practice coding and algorithm-writing by creating my own :)