If I have the list
a = ['1 2 3 4 5', '1 2 3 4 etc', '1 etc etc', '2 5 6 8', '2 7 3 9', '2 etc etc']
I want to be able to sort this based on what each element starts on. So the output I want is:
a = [['1 2 3 4 5', '1 2 3 4 etc', '1 etc etc'], ['2 5 6 8', '2 7 3 9', '2 etc etc']]
But the thing is, for my real code, I won't know have many strings starts with a '1' or with a '2', so therefore I can't divide the list based on a fixed value, is there a way of comparing each element and combine them if they're the same?