Skip to content

Instantly share code, notes, and snippets.

@rooparsh
Last active October 16, 2020 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rooparsh/829a32a755b45f6cf7ca90379c18d26d to your computer and use it in GitHub Desktop.
Save rooparsh/829a32a755b45f6cf7ca90379c18d26d to your computer and use it in GitHub Desktop.
fun getCountries(): Map<String, String> {
val countriesMap = hashMapOf<String, String>()
val isoCountries = Locale.getISOCountries()
isoCountries.forEach {
val locale = Locale("", it)
countriesMap[locale.country.toLowerCase(Locale.getDefault())] = locale.displayCountry
}
return countriesMap.toList().sortedBy { (_, value) -> value }.toMap()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment