Cookie
Cookie

Reputation: 71

Sorting with Tuple in Python with non-Latin strings as keys

I have figured out how to sort list which return a tuple with false. This key works when language is in English but won't work when translated to Japanese.

key=lambda x:(x.name!='Iraq', x.name)

This one won't work.

key=lambda x:(x.name!='イラク', x.name)

Any idea about this?

Upvotes: 1

Views: 57

Answers (1)

Nir Alfasi
Nir Alfasi

Reputation: 53535

Add at the top of the file the following lines in order to support utf8:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

Upvotes: 5

Related Questions