Three sum, distinct triplets

Write three_sum(nums) that returns every distinct triplet [a, b, c] with a <= b <= c from the list that sums to zero, each triplet using three different positions. Order of the output does not matter.

three_sum([-1, 0, 1, 2, -1, -4])  ->  [[-1, -1, 2], [-1, 0, 1]]
three_sum([0, 0, 0, 0])           ->  [[0, 0, 0]]
three_sum([1, 2])                 ->  []

Sort, fix the first element, two pointers for the other two, and skip duplicates on all three. Quadratic; a triple loop will not finish the largest check.

def three_sum(nums):
    ...