See `?merge`. It has a `sort` argument with default `TRUE`.
See
?merge. It has asortargument with defaultTRUE.