(WHDH) — Three small cities in Massachusetts are among the top 10 in the nation, according to a recent study.

WalletHub compared more than 1,200 cities with populations between 25,000 and 100,000 across 42 key indicators ranging from housing costs to school-system quality and found that Melrose, Lexington, and Milton are desirable locations to live in.

Melrose placed fourth overall, ranking eleventh in the education and health category and eighth in the safety category. The North Shore city also has the highest percentage of its population insured.

Lexington landed sixth overall, with the second-best safety ranking, while the South Shore town of Milton came in at seventh overall, with the second-lowest crime rate.

Out of the three Massachusetts small cities that landed in the top 10, Milton came in as the most affordable, followed by Lexington and Melrose.

Needham placed just outside of the top 10, ranking 11th overall.

Newton came in at 16th, with Arlington placing in 18th.

The three best cities to live in throughout the nation are reportedly Leawood, Kansas, Brentwood, Tennessee, and Sammamish, Washington.

(Copyright (c) 2020 Sunbeam Television. All Rights Reserved. This material may not be published, broadcast, rewritten, or redistributed.)