Abstract: A computer-implemented method for encoding symbols of a current message with a variable-length code. According to a preferred embodiment, the statistics of the current message, are analyzed, wherein the symbols of the current message constitute a symbol set. Dominant symbols of the symbol set which are out of order are determined. Selected symbols of the dominant symbols are reordered in the variable-length code to reduce the size of code words of the variable-length code which represent the selected symbols.