Skip to main content

Here is a sort that I put together after some research:

            private void sort(PlayingCard[] hand)
            {
        
            int i, j;
            
            PlayingCard temp;
            
            for (i = 1; i < hand.length; i++) {
            temp = hand[i];
            j = i;
            while (j > 0 && hand[j - 1].getRank().compareTo(temp.getRank()) > 0) {
              hand[j] = hand[j - 1];
              j--;
            }
            
            hand[j] = temp;
            }
}
        

Here is a sort that I put together after some research:

            private void sort(PlayingCard[] hand)
            {
        
            int i, j;
            
            PlayingCard temp;
            
            for (i = 1; i < hand.length; i++) {
            temp = hand[i];
            j = i;
            while (j > 0 && hand[j - 1].getRank().compareTo(temp.getRank()) > 0) {
              hand[j] = hand[j - 1];
              j--;
            }
            
            hand[j] = temp;
            }
        

Here is a sort that I put together after some research:

private void sort(PlayingCard[] hand)
{
    int i, j;
    PlayingCard temp;    
    for (i = 1; i < hand.length; i++) {
        temp = hand[i];
        j = i;
        while (j > 0 && hand[j - 1].getRank().compareTo(temp.getRank()) > 0) {
            hand[j] = hand[j - 1];
            j--;
        }        
        hand[j] = temp;
    }
}
        
added 357 characters in body
Source Link

I am sorting a poker hand from smallest rank to largest, and if the deck is < 5 then inserting a new card, and sorting as needed. I am aware of a few sorting implementation but thisHere is for a class project, and we are not allowed to use any of them.sort that I put together after some research:

            private void sort(PlayingCard[] hand)
            {
        
            int i, j;
            
            PlayingCard temp;
            
            for (i = 1; i < hand.length; i++) {
            temp = hand[i];
            j = i;
            while (j > 0 && hand[j - 1].getRank().compareTo(temp.getRank()) > 0) {
              hand[j] = hand[j - 1];
              j--;
            }
            
            hand[j] = temp;
            }
        

I am sorting a poker hand from smallest rank to largest, and if the deck is < 5 then inserting a new card, and sorting as needed. I am aware of a few sorting implementation but this is for a class project, and we are not allowed to use any of them.

Here is a sort that I put together after some research:

            private void sort(PlayingCard[] hand)
            {
        
            int i, j;
            
            PlayingCard temp;
            
            for (i = 1; i < hand.length; i++) {
            temp = hand[i];
            j = i;
            while (j > 0 && hand[j - 1].getRank().compareTo(temp.getRank()) > 0) {
              hand[j] = hand[j - 1];
              j--;
            }
            
            hand[j] = temp;
            }
        
Post Undeleted by user1051043
Post Deleted by user1051043
Source Link

I am sorting a poker hand from smallest rank to largest, and if the deck is < 5 then inserting a new card, and sorting as needed. I am aware of a few sorting implementation but this is for a class project, and we are not allowed to use any of them.