вы пробовали сортировать -n
$ sort -n inputFile
This is another sentence|5
This is a sentence|10
This is the last sentence|20
вы можете переключать столбцы тоже с помощью awk
$ awk -F"|" '{print $2"|"$1}' inputFile
10|This is a sentence
5|This is another sentence
20|This is the last sentence
, комбинируя awk и sort:
$ awk -F"|" '{print $2"|"$1}' inputFile | sort -n
5|This is another sentence
10|This is a sentence
20|This is the last sentence
за комментарии
если в предложении есть цифры
$ sort -n -t"|" -k2 inputFile
This is another sentence|5
This is a sentence|10
This is the last sentence|20
this is a sentence with a number in it 2|22
и, конечно, вы можете перенаправить его в новый файл:
$ awk -F"|" '{print $2"|"$1}' inputFile | sort -n > outFile