use insertion sort and median to calculate proc