Algorithms-and-Data-Structures/Python-Insertion-Sort/insertionSort.py
2024-05-02 20:14:36 +01:00

12 lines
211 B
Python

nums = [8,90,19,12,7,6,55,98];
for i in range(len(nums)-1):
key = nums[i];
j = i-1;
while (j >= 0 and nums[j] > key):
nums[j+1] = nums[j];
j -= 1;
nums[j+1] = key;
print(nums);