The city of Toronto has long been a popular spot for expats, and as it turns out, the provincial capital is one of the best cities in the world for them.

A new ranking from InterNations took a look at 50 major cities across the globe and ranked them from best to worst for expats. Toronto managed to land itself in the top 20, coming in at number 19, meanwhile the other Canadian city on the list -- Vancouver -- sat in the bottom 10, ranking just 43rd.

READ: Toronto Ranks 24th on List of World's Best Cities

To form the ranking, InterNations took a look at expat responses to questions across five major categories: quality of life, ease of settling in, working abroad, personal finance, and expat essentials. These covered factors like transportation, safety, availability of recreational sports, satisfaction with social life, career prospects, freedom of expression, and even ease of dealing with government services.

The ranking also factored in the Quality of Life Index, in which Toronto ranked 21st overall, based on its rankings of 18th for leisure options, 34th for travel and transit, 17th for health and well-being, 15th for safety and security, and 21st for environment and climate. Vancouver ranked just a few spots below on the Quality of Life Index, coming in 23rd.

When it comes to ease of settling in, Toronto came 20th while Vancouver ranked 35th. Interestingly, Toronto ranked relatively high when it came to the subcategories of "culture and welcome," and "local friendliness," coming in 12th and 14th, respectively, but ranked 32nd in "finding friends." Vancouver was considered even harder for finding a new friend group, coming in 45th, with roughly three in 10 expats describing local residents as unfriendly.

Unsurprisingly, both Toronto and Vancouver ranked extremely low on the Personal Finance Index, coming in 46th and 50th, respectively, with just London, Paris, and Johannesburg between them. In fact, when it comes to housing, Toronto ranked 37th and Vancouver ranked 48th out of the 50 cities. One Russian expat who responded to the survey wrote that "Toronto has become totally unaffordable for a lot of people," and more than three-quarters of all Toronto survey respondents (76%) said they find housing unaffordable, compared to 43% worldwide.

For those looking for a more expat-friendly metropolis, the highest-ranking city in the world overall is Valencia, Spain. Expats there find that public transportation is affordable, there are great opportunities for recreational sports, and they are happy with their social life.

Rounding out the top 10, Dubai came in second, followed by Mexico City, Lisbon, Madrid, Bangkok, Basel, Melbourne, Abu Dhabi, and Singapore.

On the opposite end of the spectrum, Vancouver is ranked only above Milan, Hamburg, Hong Kong, Istanbul, Paris, Frankfurt, and, in last place, Johannesburg.