Sort last column numerically descending with GNU awk:
awk '{ # save current row in array with current row number as index row[NR]=$0 # save current last field in array with current row number as index last[NR]=$NF } END{ # sort array "last" numerically ("num") based on its # values ("val") descending ("desc") PROCINFO["sorted_in"]="@val_num_desc"; for(i in last) print row[i] }' file As one line:
awk '{ row[NR]=$0; last[NR]=$NF } END{ PROCINFO["sorted_in"]="@val_num_desc"; for(i in last) print row[i] }' file Output:
hello my name is Jordan: 476 hello my name is Manu: 98 hello my name is Joi: 45 hello my name is Loi: 23 hello my name is John: 4
See 8.1.6 Using Predefined Array Scanning Orders with gawk for more sorting algorithms and 8 Powerful Awk Built-in Variables – FS, OFS, RS, ORS, NR, NF, FILENAME, FNR