orderedForDisplay method
Re-order the Cards for value-appropriate display (e.g. the hand "5h3cAc3h3d" will display as "3h3d3cAc5h").
Implementation
OrphanHand orderedForDisplay(HandInterface h) {
List<Card> hIn = h.toList();
assert(hIn.length == 5);
assert(ranks.length == 5);
OrphanHand hOut = OrphanHand();
for (int i = 0; i < ranks.length; i += 1) {
Rank r = ranks[i];
Card found = Card.None;
int fIndex = -1;
for (int j = 0; j < hIn.length; j += 1) {
if (hIn[j].rank == r && hIn[j] > found) {
found = hIn[j];
fIndex = j;
}
}
assert(fIndex >= 0);
assert(found == hIn.removeAt(fIndex));
hOut.push(found);
}
assert(hOut.length == 5);
return hOut;
}