Lab Exercise 6 : (Using References with an Array)

Write a program that opens a file (specified on the command line) and reads the contents into an array. Pass the array (as a reference) to a subroutine that should sort the array in the appropriate order (forward or reverse).

Your program should be written to handle the following three cases:

(1) If no other command line parameter (or an invalid parameter) is provided, your program should show help which explains the syntax of your command line parameters.

(2) If a command line parameter of -f is given, your program should sort the array in A-Z order and then print the results to the screen.

(3) If a command line parameter of -r is given, your program should sort the array in reverse order (Z-A) and then print the results to the screen.

Your program should be written so that the -f or -r parameter must be entered before the file name parameter.

The printing in your program should not be performed in the subroutine in which the sorting occurs.

Your program must use references to accomplish this goal.

Your program must be capable of responding properly to file I/O problems (eg. file does not exist) as you learned in Lab 6.

You should use the following list of (mostly) countries for the contents of your input text file.

Egypt
Russia
India
Israel
Antartica
Tibet
Vietnam
Sudan
China
Australia
Nepal 
Brazil
Morocco 
Argentina
Italy
Cuba
New Zealand
Tierra del Fuego
Mali 
Phillipines
Greece
Japan
Crimea
Cambodia 
Easter Island
Greenland
North Korea
Galapagos Islands
