nix

Date stamp

date '+%Y%m%d-%H%M'

Backup file

cp myfile.txt ~/archive/myfile.(date '+%Y%m%d-%H%M').txt

Sort and save

sort -o myfile.txt myfile.txt