This section describes the functions that performs Move To Front (MTF) data transform method. The basic idea is to represent the symbols of the source sequence as the current indexes of that symbols in the modified alphabet. This alphabet is a list where frequently used symbols are placed in the upper lines. When the given symbols occurs it is replaced by its index in the list, then this symbol is moved in the first position in the list, and all indexes are updated. For example, the sequence “baabbfffacczzdd” contains symbols that form the ordered ‘alphabet'{'a', 'b', 'c', 'd', 'f', 'z'}. The function will operate in the following manner:

Move To Front Operation
source destination alphabet
    0, 1, 2, 3, 4, 5, 6
    'a', 'b', 'c', 'd', 'f', 'z'
b 1 'b', 'a', 'c', 'd', 'f', 'z'
a 1 'a', 'b', 'c', 'd', 'f', 'z'
a 0 'a', 'b', 'c', 'd', 'f', 'z'
b 1 'b', 'a', 'c', 'd', 'f', 'z'
f 4 'f', 'b', 'a', 'c', 'd', 'z'
f 0 'f', 'b', 'a', 'c', 'd', 'z'
f 0 'f', 'b', 'a', 'c', 'd', 'z'
a 2 'a', 'f', 'b', 'c', 'd', 'z'
c 3 'c', 'a', 'f', 'b','d', 'z'
c 0 'c', 'a', 'f', 'b', 'd', 'z'
z 5 'z', 'c', 'a', 'f', 'b', 'd'
z 0 'z', 'c', 'a', 'f', 'b', 'd'
d 5 'd', 'z', 'c', 'a', 'f', 'b'
d 0 'd', 'z', 'c', 'a', 'f', 'b'

Finally, the function returns the destination sequence: 11014002305050.

These transformed data can be used for the following effective compression. This method is often used after Burrows-Wheeler transform.