How did they decide the international dialling codes?

I know that there are different world areas for country codes - such as 4* for parts of europe, but how did they decide which country would get to be 41, 42 or 43 or whatever?

Was it done by phone density. phone poplation, alpabetical order of the country name in the mother tongue, something else, or was it otherwise completely arbitrary?

Thanks very much?
W.

This link traces the development of the IDD codes: World Telephone Numbering Guide

But it doesn’t shed much light on the choice of numbers, which looks pretty arbitrary within each “world group”.

And another link with a bit more info.