diff --git a/src/CountryLoader.php b/src/CountryLoader.php index 115e43d..e6493d6 100644 --- a/src/CountryLoader.php +++ b/src/CountryLoader.php @@ -54,6 +54,11 @@ public static function countries($longlist = false, $hydrate = false) static::$countries[$list] = json_decode(static::getFile(__DIR__.'/../resources/data/'.$list.'.json'), true); } + // Sort countries by name in ascending order + usort(static::$countries[$list], function ($a, $b) { + return strcmp($a['name'], $b['name']); + }); + return $hydrate ? array_map(function ($country) { return new Country($country); }, static::$countries[$list]) : static::$countries[$list];