Problem facing to compare different column and print out record with smallest number

Hi,

Input file 1 :

37170   37196   77      51
37174   37195   73      52
37174   37194   73      53

Desired Output file 1 :

37170   37196   77      51

Input file 2 :

37174   37195   73      0
37170   37196   77      0

Desired Output file 2 :

37174   37195   73      0

Input file 3 :

37170   37196   77      51

Desired Output file 3 :

37170   37196   77      51

I would like to print out the record with smallest number through compare the data in column 3 and 4.
If the smallest number are in same column (either column 3 or 4, Input file 2). In that case, I would like to compare the other column and print out the line that record smallest number in both column 3 and 4.

Below is the command that suggested by Subbeh and Klashxx,

awk '{x=$3<$4?$3:$4; i=i?i:x ;if(x<=i){i=x; s=$0}} END{print s}' infile
awk 'NR==1{L=$NF<$(NF-1)?$NF:$(NF-1)}$(NF-1)<= L{L=$(NF-1);t=$0};$NF<=L{L=$NF;t=$0}END{print t}' infile

It work fine for Input file 1 and Input file 3.
Unfortunately, it won't work for cases like Input file 2.

Thanks for any advice.

This thread duplicates the thread Problem to print out record got smallest number in specific column.

This thread is closed.