I would like to turn this data in Python (sorted alphabetically):
test = [['ma', 'e', 'wa', 'ka'], ['ma', 'haa', 'laa'], ['ma', 'ka', 'm', 'haa', 'laa', 'ca', 'j', 'ra'], ['ma', 'ra'], 'ma']
Into a multidimensional array with its items sorted by the amount of items in each list like this:
test = ['ma', ['ma', 'ra'], ['ma', 'haa', 'laa'], ['ma', 'e', 'wa', 'ka'], ['ma', 'ka', 'm', 'haa', 'laa', 'ca', 'j', 'ra']]
If you just looked at the length, I'd like it to go from [4, 3, 8, 2, 1] to [1, 2, 3, 4, 8] but I don't necessarily want the solution to be specific to this example.