{AGRTMLOIH}

{HIOLMTRGA}

{ALGORITHM}

The following is a description of the randomized algorithm in pseudocode:

while not sorted (deck): shuffle deck

An implementation in C:

c implementation

An implementation in Python:

python implementation