I'm new to python and have an array, where each element is an array of tuples. I need to sort the tuples in the inner array by the first element in the tuple. My array looks something like this:
[[(u'10:30', u'11:20'), (u'08:30', u'09:20')], [(u'14:30', u'15:50'), (u'10:00', u'11:20'), (u'10:30', u'11:20'), (u'13:00', u'14:20')], [(u'10:30', u'11:20'), (u'08:30', u'09:20')], [(u'14:30', u'15:50'), (u'10:00', u'11:20'), (u'13:00', u'14:20')], [(u'10:30', u'11:20'), (u'08:30', u'09:20')]]
I tried doing something like
for index, elm in array:
array[index] = sorted(elm, key=lambda x: x[0])
But I get the ValueError: need more than 0 values to unpack. Not sure if my syntax is off or something
The expected result is
[[ (u'08:30', u'09:20'), (u'10:30', u'11:20')], [ (u'10:00', u'11:20'), (u'10:30', u'11:20'), (u'13:00', u'14:20'), (u'14:30', u'15:50')], [(u'08:30', u'09:20'),(u'10:30', u'11:20') ], [ (u'10:00', u'11:20'), (u'13:00', u'14:20'), (u'14:30', u'15:50'),] [ (u'08:30', u'09:20'), (u'10:30', u'11:20')]]