Insertion Sort

Instructions:

Use Insertion Sort to sort the table given below in ascending order. Click on an item to select it and copy its value to another position by clicking on the new position.

  1. def inssortshift(A):
  2. for i in range(1, len(A)): # Insert i'th record
  3. temp = A[i]
  4. j=i
  5. while (j > 0) and (temp < A[j-1]):
  6. A[j] = A[j-1]
  7. j -= 1
  8. A[j] = temp

Table to be sorted

  1. 330
  2. 361
  3. 312
  4. 293
  5. 634
  6. 415
  7. 256
  8. 507
  9. 268
  10. 809

temp variable

  1. 76