Implement insertInOrder and sort