#include <bits/stdc++.h>
using namespace std;
//sorting of line data
//similar to dictionary-order sorting
int T, N;
const int n=1001;
struct data
{
int cnt;
int a[n];
}d[n];
bool cmp(data x, data y)
{
//similar to sorting by dictionary-order(keep the head aligned and sort from head to tail)
int i,j;
int lenx=x.cnt, leny=y.cnt;
int len=min(lenx,leny);
for(i=0;i<len;++i){
if(x.a[i]==y.a[i]) continue;
return x.a[i]>y.a[i];
}
return lenx>leny;
}
int main()
{
cin>>T;
while(T--)
{
cin>>N;
int i,j,temp;
for(i=0;i<N;++i){
j=0;//put j=0 int the first layer loop
while(cin>>temp&&temp!=-1){
d[i].a[j]=temp;
j++;
}
d[i].cnt=j;
}
sort(d,d+N,cmp);
for(i=0;i<N;++i){
for(j=0;j<d[i].cnt;++j)
printf("%d%c",d[i].a[j]," \n"[j==d[i].cnt-1]);
}
}
return 0;
}
结构体里的数组本身不是乱序的么?