1: Create the sum for each pair, like this: [sum,list_of_pairs]

2; sort the pairs by key.

3: find the match condition pairs, and filter them out.

```
def fourSum(self, num, target):
num=sorted(num);
sum2={}
for i in range(len(num)):
for j in range(i+1,len(num)):
sumij=num[i]+num[j];
if(sumij not in sum2):
sum2[sumij]=[];
sum2[sumij].append((i,j));
sum2 = sorted(sum2.items(), key=lambda x:x[0])
res=set();
i,j=0,len(sum2)-1;
while(i<=j):
total=sum2[i][0]+sum2[j][0];
if(total==target):
for k1 in range(len(sum2[i][1])):
for k2 in range(len(sum2[j][1])):
a,b=sum2[i][1][k1];
c,d=sum2[j][1][k2];
items= set([a,b,c,d]);
if(len(items)==4):
newItem=[num[fi] for fi in items];
newItem=tuple(sorted(newItem));
res.add((newItem));
i+=1;
j-=1;
elif(total<target):
i+=1;
else:
j-=1;
resNums= [];
for item in res:
resNums.append([i for i in item]);
return resNums;
```