We can use redirection to send the output of one command to a file. In this example we use sort with a dlimeter of a comma (,) listing numerical column 3 of the stats.txt and storing it in a new file sortedstats.txt

sort -t, -k3n stats.txt > sortedstats.txt

where -t, = field separator of comma  and -k3n = column 3 numerical