Merge files based on key

Hi Friends,
Can any one help me with merging these file based on two columns :

File1:

A|123|99|SAMS
B|456|95|GEORGE
D|789|85|HOVARD

File2:
S|123|99|NANcY|6357
S|123|99|GREGRO|83748
A|456|95|HARRY|827|somers
S|456|95|ANTONY|546841|RUDOLPH|7263
B|456|95|SMITH|827|BOISE STATE|834
B|789|85|TIM|732643|NEW YORK|90723409

Output should be like this:
A|123|99|SAMS
S|123|99|NANcY|6357
S|123|99|GREGRO|83748
B|456|95|GEORGE
A|456|95|HARRY|827|somers
S|456|95|ANTONY|546841|RUDOLPH|7263
B|456|95|SMITH|827|BOISE STATE|834
D|789|85|HOVARD
B|789|85|TIM|732643|NEW YORK|90723409

Thanks in advance for your help.

S :slight_smile:

if your sort has -m

sort -n -t\| -k2 -k3 -m file1 file2

else:

cat file1 file2 | sort -n -t\| -k2 -k3

sort -n -t\| -3 -5 -m file1 file2 ins not working.
is diplays the files seperately
I would like to merge that.

Thank you

You seem to be missing a couple of k's in your code.