The order of connecting two cars does matter for safety reasons. One of the most important considerations is to keep sparks away from the dead battery. Under some fault conditions a lead-acid battery will produce hydrogen gas, which is highly explosive in the presence of sufficient oxygen.
First, the two positive cables are connected while the cars are not touching each other. With no connections between the chassis of the two cars there is no current path hence no possibility of sparks.
Then the ground connection is made to the chassis of the car with the dead battery. Still no chance for sparks because no complete circuit was formed.
Finally, the ground connection to the chassis of the car with the good battery is made. Some sparking is likely, but this will be well removed from the dead battery.
Here a link to what many believe is the most authoritative source for such advice: https://www.cartalk.com/content/although-its-too-late-me-ive-already-done