Keeping the previous key ordering when joining two dataframes



When joining the following dataframes,
name = DataFrame(Order = [400, 3, 1], Name = ["John Doe", "Jane Doe", "Joe Blogs"])
job = DataFrame(Order = [400, 2, 1], Job = ["Lawyer", "Doctor", "Farmer"])
namejob = join(name, job, on = :Order)

one gets:
Row Order Name Job
1 1 "Joe Blogs" "Farmer"
2 400 "John Doe" "Layer"

However I would like to get instead:
Row Order Name Job
1 400 "John Doe" "Layer"
2 1 "Joe Blogs" "Farmer"

Is it possible to join two dataframes and keep the initial ordering without re-sorting or incurring some other overhead?

Thank you in advance


I guess with ‘initial ordering’ you mean initial ordering of the left DataFrame (in this case name)? (a join will almost always include some sorting). You can achieve that by adding the keyword kind = :left. It will not do exactly what you want, though, as that will keep the full left DataFrame, including Jane Doe). You can use completecases to weed out rows like Jane Doe, but AFAICS there is no way to do what you want in a single operation.