Sorting initial location results alphabetically

There have been a few support requests related to sorting the initial locations that display within the locator alphabetically so it makes sense to have a tutorial post about it. When using the full map start or default location setting along with the default or other custom post type, the initial display of locations on the map will be sorted by post date, which is the default order with WP_Query. This can be modified without too much trouble using the location data¬†filter¬†and PHP’s usort function. The following code example can be placed within your theme’s functions.php file: