implemented insertion sort in prediction algorithm