Implementation of insertion sort algorithm