Home CPSC 220

String Sorting

 

Objective

To be able to use apply the bubble sort algorithm and use arrays of Strings.
 

Task

For this lab exercise, you are to write a program that reads in a number of Strings from the user, stores them in an array, and prints them out twice, once sorted alphabetically from A-Z, and then sorted alphabetically from Z-A.


 

Details


 

Example Run


Enter the number of strings: 5
Enter a string: pear
Enter a string: apple
Enter a string: pineapple
Enter a string: orange
Enter a string: banana

Sorted:
apple
banana
orange
pear
pineapple

Reverse sorted:
pineapple
pear
orange
banana
apple

 

Submitting

When your program works, email the code to ifinlay@umw.edu.

Copyright © 2024 Ian Finlayson | Licensed under a Creative Commons BY-NC-SA 4.0 License.