Builds a sorted prefix by inserting each new element into its correct position.
for i from 1 to n-1: key = a[i] while j >= 0 and a[j] > key a[j+1] = a[j] a[j+1] = keydone