41Name Sorter

Alphabetizing the contents of a file, or sorting its contents, is a great way to get comfortable manipulating a file in your program.

Create a program that reads in the following list of names:

 
Ling, Mai
 
Johnson, Jim
 
Zarnecki, Sabrina
 
Jones, Chris
 
Jones, Aaron
 
Swift, Geoffrey
 
Xiong, Fong

Read this program and sort the list alphabetically. Then print the sorted list to a file that looks like the following example output.

Example Output

 
Total of 7 names
 
-----------------
 
Ling, Mai
 
Johnson, Jim
 
Jones, Aaron
 
Jones, Chris
 
Swift, Geoffrey
 
Xiong, Fong
 
Zarnecki, Sabrina

Constraint

  • Don’t hard-code the number of names.

Challenges

  • Implement this program by reading in the names from the user, one at a time, and printing out the sorted results to a file.

  • Use the program to sort data from a large data set and see how well it performs.

  • Implement this program in a functional programming language and compare the programs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.43.216