GNU awk:
awk 'BEGIN {PROCINFO["sorted_in"]="@ind_num_asc"} \
{idx=gensub(".*\\s+([0-9]+).*", "\\1", "g"); arr[idx]=$0} \
END{for (i in arr) print arr[i]}' file.txt
PROCINFO["sorted_in"]="@ind_num_asc" variable sets (associative) array sort order based on numeric index
{idx=gensub(".*\\s+([0-9]+).*", "\\1", "g"); arr[idx]=$0} arr ,
END{for (i in arr) print arr[i]}
, :
PROCINFO["sorted_in"]="@ind_num_desc"
:
% cat file.txt
This test took 1201ms to execute
The IO operation cost 113ms
Main thread have been executing for 16347ms
% awk 'BEGIN {PROCINFO["sorted_in"]="@ind_num_asc"} {idx=gensub(".*\\s+([0-9]+).*", "\\1", "g"); arr[idx]=$0} END{for (i in arr) print arr[i]}' file.txt
The IO operation cost 113ms
This test took 1201ms to execute
Main thread have been executing for 16347ms