A = [[1, 2, 3], [1, 3, 7], [2, 1, 3], [8, 9, 6], [3, 7, 9], [2, 3, 8], [1, 
    2, 4]]
A = sorted(A, key=lambda x: x[0])
B = [[A[0]]]
for list in A[1:]:
    if B[-1][-1][0] == list[0]:
        B[-1].append(list)
else:
    B.append([list])
B
[[[1, 2, 3], [1, 3, 7], [1, 2, 4]], [[2, 1, 3], [2, 3, 8]], [[3, 7, 9]], [[
    8, 9, 6]]]
Most efficient way to break python list into sublists via key while preserving the order