简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM