added javascript function for insertion sort