more work on functional insertion sort