I've got this code to sort a list without using the sorted function in python. The output is the opposite to what is expected (largest to smallest rather than smallest to largest)
Changing the < to a > seems to help but im not sure why this is
lista=[2,1,5,1,3,6]
for i in range(len(lista)):
for l in range(len(lista)):
if i==l:
continue
if lista[l]<lista[i]:
temp=lista[i]
lista[i]=lista[l]
lista[l]=temp
print(lista)
expected output list that is smalled to largest, but getting the opposite unless I change the < sign to a > sign, but I'm not sure why this is?