They were both created simultaneously. They are basically the same game so the developers would have built the "base" game with the Pokemon and maps, then tailored each game separately, putting different Pokemon in certain places.
As for sales, I don't know individual sales figures but Diamond was always above Pearl in the charts so it clearly sold more.