I am trying to sort my array to print it out according to the suits e.g. S10, S6, H11, C4, D10 etc. I have tried adding Arrays.sort but it doesnt work. Please advice.

    private void transfer2D(String[][] twoD, String[] strArray)
    {
        int i = 0;
        for( int suit = 0; suit < 4; suit++ )
        {
            for( int rank = 0; rank < 13; rank++ )
            {
                twoD[suit][rank] = strArray[i++];
            }
        }
    }

    private void print2D_1(String[][] twoD)
    {
        int count = 0;
        System.out.println("Rearrange the cards - 1");
        System.out.println();
        for(int suit = 0; suit < 4; suit++)
        {
            for(int rank = 0; rank < 13; rank++ )
            {
                Arrays.sort(twoD);
                System.out.print("  " + twoD[suit][rank]);
            }
            System.out.println();
        }

    }

Please re-read my previous answer to you. You need a Comparator.
Arrays.sort(array) without a Comparator only works if the contents of the array have a "natural sort order" (eg ints) or are Objects that implement the Comparable interface to define their natural order. In your case you have a nested array, so the contents of the main array are just more arrays, with no natural sort order.
(NB: all enums automatically implement Comparable, with a natural sort order that is the same as the order in which you declared the members, So they will sort in that order without you having to do anything else.)

It's unclear what you are trying to achieve with all this code. What is the purpose of the 2D array? Maybe a brief description of the desired output would enable us to advise on how best to achieve it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.