FAA: May I log as cross-country a flight with two or more short legs?
From a 2008 FAA interpretation sent to E. Thomas Sisk:

… cross-country flight time is defined as time acquired during a flight that includes a point of landing that is at least a straight-line distance of more than 50 nm from the original point of departure, not the original point of any flight leg. There is no requirement that any specific leg must be 50 nm. Moreover, a cross-country flight may include several legs that are less than a straight-line distance of more than 50 nm from the original point of departure. Nevertheless, at least one leg of the cross-country flight, however long by itself, must include a point of landing that is at least a straight-line distance of more than 50 nm from the original point of departure (i.e. of the flight, not of that particular leg).
Given the above analysis, the answer is each cross-county flight used to meet the aeronautical experience requirements under 14 CFR §61.1 (b)(3) must include one leg that includes a landing that is at least a straight-line distance of more than 50 nm from the original point of departure.

From the above, it is pretty clear that the order of flying does not matter and you can log the whole flight.
Also, see this AOPA response.