sorted list merge implementation