Practice
Sort By Initials
You have received a file named text.dat containing a set
of client records. Each record is delimited
by a newline character and consists of
two initials in its first 2 character
positions and the full client name in the remaining
positions.
Write a complete program that
- reads all records in the file
- displays the client names in alphabetic order
based on the initials in the first 2 character
positions of a record: use the 2nd initial for
your primary sort and the 1st initial for your
secondary sort
You may assume that
- there are no more than 500 records on the file
- each record contains no more than 80 characters
excluding the newline delimiter
- there are no errors in reading the file records
and
- all initials are in uppercase
For example, if the file records look like
AB Albert Bumble
FG Fred Goofoff
GF Gary Flintstone
DD Donald Duck |
the output of your program looks something like
AB Albert Bumble
DD Donald Duck
GF Gary Flintstone
FG Fred Goofoff |
|