I know how to compare the hands, you seem to have misunderstood.
The issue is that I've had to re-write the order of things. First I have to look for flushes. If there's a flush, check if a straight can be made out of thel cards that match the suit that the flush is in. If so, then we have a straight flush.
All cards being checked for a straight must always be sorted into order, so that the highest possible straight can be determined. For example:
1) Qh, Js, 10d, 8d, Ks, 2s, 9c is a straight of 9, 10, J, Q, K. However, it also has a straight of 8, 9, 10, J, Q. In order to properly evaluate the hand we re-order the input to Ks, Qh, Js, 10d, 9c, 8d, 2c. It is then trivial to check that there is a sequence beginning with Ks that decrements 5 times. This means that the false Jack high straight is not returned.
2) 6h, 7h, 6d, 9c, 8d, 5h, 8s is a straight of 5, 6, 7, 8, 9. The issue here is that there is a duplicate 6 and a duplicate 8. So, when in order it would be viewed as 9c, 8s, 8d, 7h, 6d, 6h, 5h. There is no simple decrementing pattern here. So, what I had to do is alter my algorithm to ignore cases where number pairs are equal:
9->8 decrements, 8->8 ignored, 8->7 decrements, 7->6 decrements, 6->6 ignored, 6->5 decrements.
There are 4 decrements linking 9 to 5 without a broken link (i.e. 7->4 does not match b = a-1), therefore there is a 9 high straight here.
I have no proiblem understanding the logic behind it, I was asking if anyone knew where I could find a pre-written algorithm to save me the time and effort.