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 b
l = [1,2,3,4,5,6,7]
def my_function(a,b):
# your comparison between a and b
# return or print values or what ever you want to do based on the comparison
reduce(my_function, l)
reduce will automatically take care of i and i + 1.