A 5w40 motor oil is thinner compares to a 10w40 motor oil in same low temperature conditions - because the "W" number is lower.
So, the "W" shows better cold weather performance, the 5w flows better than a 10w, simply just consider the "W" stands for 'winter'. It's a relative number to indicate how easily it will allow an engine to "turn over" at low temperatures instead of viscosity reference.
As for the final number, says 10w40 and 10w50. So, what the 40 and 50 mean?
The final number is based upon the kinematic viscosity at 100 Centigrade. Is a rating, how a monograde '40' and a monograde oil '50' behave at tempreature 100 Centigrade.
As you know solid-liquid get thinner when temperature increases. So, the engine oil will eventually 'thin-out' as the engine get hotter. When then oit get thiner to very thin liquid and finally almost as thin as water and the extreme end would be the oil turns gaseous - the oil will loose its 'lubrication' properties (no more behave like engine oil). In simpler words, a 10w50 performs better than 10w40 in hotter temperature.
A small note from Mercedes-Benz Approved Engine Oils for the Latest Engines that might interest you: 5W-30 oil viscosity is not approved for use in all AMG engines thus I don't think any turbo engine or high stress-strained engine should be using 5W-30, must at least use 5W-40 or above.