I need to sort this list without using built-in sort(). I figured I could use insertion sort, but I've never really used it before. My code doesn't seem to be working. What is wrong with it? Thank you.
fruits = ['grape', 'banana', 'strawberry', 'apple', 'peach', 'cherry']
for i in range(1, len(fruits)):
tmp = fruits[i]
j = i-1;
while (j>0 and fruits[j] > tmp):
fruits[j+1] = fruits[j]
j = j-1
fruits[j+1] = tmp
print(fruits)
insertion_sortanywhere? If you did, you'd get a NameError, aslensisn't defined.;- they're not required...