Wolfram Language

Multilingual Functionality

Sorting Cities and Building a Dictionary

In Version 11, it is possible to sort strings using an alphabetic comparison method defined for each language.

For example, get a group of cities from Denmark.

Click for copyable input
cityNames = EntityValue[ GeoEntities[ Entity["AdministrativeDivision", {"Nordjylland", "Denmark"}], "City"], "Name"];

Now sort these cities using AlphabeticSort but setting the languages separately to Danish and English, to be able to appreciate the differences between them.

Click for copyable input
sortedCityNames = Transpose[{AlphabeticSort[cityNames, "Danish"], AlphabeticSort[cityNames, "English"]}];
show complete Wolfram Language input
Click for copyable input
TextGrid[Join[ Sequence @@ (Prepend[#, {"Danish", "English"}] & /@ Partition[sortedCityNames, UpTo[14]]), 2], Frame -> {None, None, {{{1, 1}, {1, 6}} -> True, {{1, 15}, {1, 6}} -> True, {{1, 15}, {1, 2}} -> True, {{1, 15}, {1, 4}} -> True}}]

Create a sorted dictionary translating a random sample of words from Swedish to English.

Click for copyable input
words = AlphabeticSort[ RandomSample[WordList[Language -> "Swedish"], 6], "Swedish"];
Click for copyable input
sortedTranslations = AlphabeticSort[#, "English"] & /@ WordTranslation[words, "Swedish" -> "English"];
show complete Wolfram Language input
Click for copyable input
TextGrid[{words, Column /@ sortedTranslations}, Frame -> All]

Related Examples

de es fr ja ko pt-br ru zh