next up previous
Next: What to turn in Up: Assignment 10: Cards and Previous: Shuffle the deck

Sort the deck

1.
Write a static method called findHighestCard that takes an array of cards and an index as arguments, and that finds and returns the index of the highest-ranking card in the deck, starting at the given index. Of course, you will want to use the compare method to compare cards to one another.
2.
Write a static method called sortDeck that takes an array of cards as an argument and that sorts the deck so that the highest ranking card is first. Using the findHighestCard method, you can write this method in only about four lines, and you will find that the result is disturbingly similar to shuffleDeck.



Allen B. Downey
4/21/1998