Sorting list containing multiple datatypes in Python -
how sort list containing multiple datatypes in python 3.4? example:- lixt=["tak","jil","son",54,84] lixt.sort()
error: typeerror: '<' not supported between instances of 'int' , 'str'
please proper solution
use sorted(your_list, key=str) simple cases when can sort string representation of item
l = ["tak","jil","son",54,84] sorted(l, key=str) output: [54, 84, 'tak', 'jil', 'son']
Comments
Post a Comment