Inserts data into a stream based on a compare function