Given a file1:
13 a b c d 5 f a c d 7 d c g a 14 a v s d
and a file2:
7 x 5 c 14 a 13 i
I would like to sort
Simple solution
for S in $(cat file2 | awk '{print $1}'); do grep $S file1; done