Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List = [
- "Afghanistan", "Albania", "Algeria", "Andorra", "Angola",
- "Antigua and Barbuda", "Argentina", "Armenia", "Australia",
- "Austria", "Azerbaijan", "Bahamas, The", "Bahrain", "Bangladesh",
- "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bhutan",
- "Bolivia", "Bosnia and Herzegovina", "Botswana", "Brazil", "Brunei",
- "Bulgaria", "Burkina Faso", "Burma", "Burundi", "Cambodia",
- "Cameroon", "Canada", "Cape Verde", "Central African Republic",
- "Chad", "Chile", "China", "Colombia", "Comoros",
- "Congo, Republic of the", "Costa Rica", "Croatia", "Cuba", "Cyprus",
- "Czech Republic", "Congo, Democratic Republic of the", "Denmark",
- "Djibouti", "Dominica", "Dominican Republic", "East Timor",
- "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea",
- "Estonia", "Ethiopia", "Fiji", "Finland", "France", "Gabon",
- "Gambia, The", "Georgia", "Germany", "Ghana", "Greece", "Guatemala",
- "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Honduras", "Hungary",
- "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland",
- "Israel", "Italy", "Ivory Coast", "Jamaica", "Japan", "Jordan",
- "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos",
- "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein",
- "Lithuania", "Luxembourg", "Macedonia", "Madagascar", "Malawi",
- "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands",
- "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova",
- "Monaco", "Mongolia", "Montenegro", "Morocco", "Mozambique",
- "Namibia", "Nauru", "Nepal", "Netherlands", "New Zealand",
- "Nicaragua", "Niger", "Nigeria", "North Korea", "Norway", "Oman",
- "Pakistan", "Palau", "Palestine", "Panama", "Papua New Guinea",
- "Paraguay", "Peru", "Philippines", "Poland", "Portugal", "Qatar",
- "Romania", "Russia", "Rwanda", "Saint Kitts and Nevis",
- "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa",
- "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal",
- "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Slovakia",
- "Slovenia", "Solomon Islands", "Somalia", "South Africa",
- "South Korea", "South Sudan", "Spain", "Sri Lanka", "Sudan",
- "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan",
- "Tajikistan", "Tanzania", "Thailand", "Togo", "Tonga",
- "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan",
- "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates",
- "United Kingdom", "United States", "Uruguay", "Uzbekistan",
- "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Yemen",
- "Zambia", "Zimbabwe"]
- order = 'EFMIRNOVQADTWKLUBPCJYSHGXZ'
- orderdict = dict(zip(order, list(range(len(order)))))
- def orderweight(name):
- name = name.upper()
- name = ''.join([s for s in list(name) if s in list(order)])
- weight = 0.0
- for i in range(len(name)):
- weight = weight + float(orderdict[name[i]])/len(order)**i
- return weight
- result = sorted(List, key=orderweight)
- print (result)
Advertisement
Add Comment
Please, Sign In to add comment