I have a list A
containing many sublists. I want to reorganize this list based on the first element of each sublist i.e. in ascending order. I present the current and expected output.
A=[[27, 31, 32, 36], [30, 34, 35, 39], [28, 32, 33, 37], [29, 33, 34, 38]]
C=[]
for i in range(0,len(A)):
B=A[i][0]
C.append(B)
C.sort()
print(C)
The current output is
[27, 28, 29, 30]
The expected output is
[[27, 31, 32, 36], [28, 32, 33, 37], , [29, 33, 34, 38], [30, 34, 35, 39]]