Skip to content

Instantly share code, notes, and snippets.

@bartenbach
Created January 16, 2012 00:47
Show Gist options
  • Save bartenbach/1618267 to your computer and use it in GitHub Desktop.
Save bartenbach/1618267 to your computer and use it in GitHub Desktop.
public void sortHand(){
LinkedList<Card> spades = new LinkedList<Card>();
for(Card x : playerHand){
if(x.getSuit() == Suit.SPADES){
spades.add(x);
}
Collections.sort(spades);
}
LinkedList<Card> diamonds = new LinkedList<Card>();
for(Card x : playerHand){
if(x.getSuit() == Suit.DIAMONDS){
diamonds.add(x);
}
Collections.sort(diamonds);
}
LinkedList<Card> clubs = new LinkedList<Card>();
for(Card x : playerHand){
if(x.getSuit() == Suit.CLUBS){
clubs.add(x);
}
Collections.sort(clubs);
}
LinkedList<Card> hearts = new LinkedList<Card>();
for(Card x : playerHand){
if(x.getSuit() == Suit.HEARTS){
hearts.add(x);
}
Collections.sort(hearts);
}
LinkedList<Card> temp = new LinkedList<Card>();
temp.addAll(hearts);
temp.addAll(clubs);
temp.addAll(diamonds);
temp.addAll(spades);
playerHand = temp;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment