@@ -1,6 +1,7 @@
11module Data.CountryCodes (
22 CountryCode(..)
33 , allNames
4+ , countryList
45 , fromMText
56 , fromText
67 , fromMName
@@ -13,7 +14,13 @@ import Control.Arrow ((&&&))
1314import Data.Text (Text)
1415
1516import Data.CountryCodes.ISO31661
17+import Data.List (sortBy)
18+import Data.Function (on)
1619
1720-- | list all codes with names
1821allNames :: [(CountryCode,Text)]
19−allNames = map (id &&& toName) $ enumFrom minBound
22+allNames = map (id &&& toName) $ enumFrom minBound
23+
24+-- | list of names sorted by alphabetical order, with country code
25+countryList :: [(Text,CountryCode)]
26+countryList = sortBy (compare `on` fst) $ map (toName &&& id) $ enumFrom minBound