I am trying to rank an array of sorted poker cards, but am unable to find a way to make sure the order of rank alphabets attached to the suits to go as (A-K-Q-J-T), for example my output shows HT (heart ten) to be bigger than HJ (heart joker) when it should be the other way round.
private void sort2D (String [][] twoD)
{
// to compile sorted array
ArrayList<String> toCompileSorted = new ArrayList<String> ();
for (int row = 0; row < twoD.length; row++)
{
String [] sorted2D = new String [MAXC]; // MAXC = 13
for (int column = 0; column < twoD[row].length; column++)
{
sorted2D [column] = twoD [row][column];
}
// 2d array becomes ascending only row by row, not everything
Arrays.sort (sorted2D);
// make sure it goes by A-K-Q-J-T ???
// array split according to letter ranks ??
for (String s : sorted2D)
{
toCompileSorted.add (s);
}
}
// put back into 2d array
int i = 0;
for (int row = 0; row < twoD.length; row++)
{
for (int column = 0; column < twoD[row].length; column++)
{
twoD [row][column] = toCompileSorted.get(i);
i++;
}
}
}
C6 C7 CJ CT D8 H2 HJ HT S3 S5 S6 S7 SA
5 - 3 - 1 - 4
C2 C3 C8 CK D4 D7 DK DQ H3 H7 HA HK SQ
1 - 4 - 4 - 4
C4 C9 CA CQ D2 D5 H5 H9 HQ S2 S8 S9 SJ
4 - 3 - 2 - 4
C5 D3 D6 D9 DA DJ DT H4 H6 H8 S4 SK ST
3 - 3 - 6 - 1
This is my result (ignore the numbers below each row), in the first row, CJ (club joker) is bigger than CT (club ten) but the output shows otherwise, same thing happens for other rows too.