AS3 Checking or Retrieving rummy sequences from cards

I have been thinking of a way to check or retrieve valid rummy sequences from an array of cards.
If someone has any logic idea, can you please share how to do this? ACE can be at starting or at ending.

Valid sequence: 3 or more running cards like 2,3,4 or 4,5,6,7 or J,Q,K,A or A,2,3 etc…

The problem lies here. There are two joker cards which can be substituted to any of the cards. So if the joker card(predefined at game start) is 3, then this is a valid sequence 5,3,7,8 because 3 is substituted for 6. Any idea??!! :sc::sigh: