How to sort a python list that contains float values,
list1 = [1, 1.10, 1.11, 1.1, 1.2]
or
list1 = ['1', '1.10', '1.11', '1.1', '1.2']
Expected results: list_val = ['1', '1.1', '1.2' , '1.10', '1.11'], but the returned result using the sort () method returns [1, 1.1000000000000001, 1.1000000000000001, 1.1100000000000001, 1.2] or [ '1', '1.1', '1.10', '1.11', '1.2']. But here "1,2" should be between "1.1" and "1.10".
source
share