The code for this could be similar to a pointer and count based merge sort, starting by creating a "source" array of pointers and counts for each sequence, and allocating a second "destination" array to merge the "source" array of pointers and counts into. Each pass of this algorithm merges pairs of pointers and counts based on the sequences from the "source" array into the "destination" array, reducing the number of entries in the array by about 1/2. Then pointers to the "source" and "destination" arrays are swapped, and the merge process repeated until an array of pointers and counts only has a single entry.