It is also probable that your operating system provides a utility that will sort the file.

If you wish to sort the file with a program that you write, then you must learn and implement a sort algorithm.