Example 93: Sort Records in a File

Learn how to sort records in a file and display the results.

We'll cover the following

Problem

Suppose a file contains students’ records, with each record containing the name and age of a student.

Write a program to read these records and display them in sorted order by name. The file has already been written for you.

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Note: To run your solution or our given solution, follow the following steps:

  • Click on the run button.
  • Wait for the 4 steps to complete, and then switch to the terminal tab.

Get hands-on with 1400+ tech skills courses.