Your input file is:
1 1 1 1 text1
7 9 4 2 text2
2 2 0.5 0.7 text3
5 4 1 2 text4
With this input a simple sort
will work:
$ sort << EOF
> 1 1 1 1 text1
> 7 9 4 2 text2
> 2 2 0.5 0.7 text3
> 5 4 1 2 text4
> EOF
1 1 1 1 text1
2 2 0.5 0.7 text3
5 4 1 2 text4
7 9 4 2 text2
If we amend the input to something like...
$ cat test.txt
1 3 1 1 text1
7 9 4 2 text2
2 1 0.5 0.7 text3
5 4 1 2 text4
Then the input becomes challenging. A simple sort
no longer works, and we can test other approaches:
$ sort -k1,1n -k2,2n < test.txt
1 3 1 1 text1
2 1 0.5 0.7 text3
5 4 1 2 text4
7 9 4 2 text2
This isn't what we'd expect - The first two lines of output are reversed - the highest 1/2 column value in line 1 is "3", and the highest in line 2 is "2".
The following appears to work, at least for the revised input file, but it's not pretty (my awk-fu is weak):
$ awk '{ sorton=$1; if ($2>$1) { sorton=$2 }; print $1, $2, $3, $4, $5, sorton }' < test.txt | sort -k 6 | cut -d " " -f 1-5
2 1 0.5 0.7 text3
1 3 1 1 text1
5 4 1 2 text4
7 9 4 2 text2
@Nominal-Animal and @JJoao suggested refinements, resulting in:
$ awk '{ k= $1>$2 ? $1: $2 ; print k, $0 }' test.txt | sort -g | cut -d ' ' -f 2-
2 1 0.5 0.7 text3
1 3 1 1 text1
5 4 1 2 text4
7 9 4 2 text2
(Feel free to edit this post to refine an awk
solution.)