insertion sort, took way too long to re-understand