The best way to do this is to convert the data into something easier to work with.
You have:
- a list of lists (this is fine);
- each inner list only has a single item (this is unusual);
- each item is a string (but you want to treat them as numbers);
- the strings are made up of three numeric substrings;
- separated by dots;
- except for the first, which uses commas.
Let’s break the strings up into lists of numbers:
test_data = [['1.5.34'], ['0.10.8'], ['6.15.43'], ['1.4.55'], ['1.5.53']]
data = [] # Accumulate our processed data.
for sublist in test_data:
item = sublist[0] # Extract the first (and only) string from the sublist.
item = item.replace(',', '.') # Convert commas to dots.
values = item.split('.') # Split on the dots.
numbers = [int(s) for s in values] # Convert to integers.
data.append(numbers) # And store them for further use.
Here’s a shorter way to do the same, without all the temporary variables:
test_data = [['1,5,34'], ['0.10.8'], ['6.15.43'], ['1.4.55'], ['1.5.53']]
data = [[int(s) for s in item[0].replace(',', '.').split('.')] for item in test_data]
However you do it, now we can easily sort the list-of-lists by the last number:
data.sort(key=lambda a: a[-1])
If you have more processing to do, now is probably the best time to do it, while the data is in an easy format to work with.
And finally, if you really must (but why?) we can reassemble into a list of lists containing a single string:
test_data = [['.'.join(map(str, sublist))] for sublist in data]
Putting it all together as a three step process:
test_data = [['1,5,34'], ['0.10.8'], ['6.15.43'], ['1.4.55'], ['1.5.53']]
data = [[int(s) for s in item[0].replace(',', '.').split('.')] for item in test_data]
data.sort(key=lambda a: a[-1])
test_data = [['.'.join(map(str, sublist))] for sublist in data]