Create a structure to hold each line of data, then create a list of the structures and sort the list. Then write each of the structures contents sequentially to a file.

Optionally, you could do basically the same as above but implement the IComparable interface on the structures you created to hold the data and use the List<T>.Sort() method to sort the data based on the code you placed in the CompareTo() method implementation in each structure object.