the invention is a compression method which provides the advantages of run - length compression while preserving the natural collating order of the data . the method of the invention replaces sequential repetitions of a target pattern beyond a threshold value followed by a single number which encodes both the repetition count and the collating relationship between the target pattern and the pattern which follows it in the uncollated sequence . in the preferred embodiment of the invention , the code is preceded by at least one repetition of the pattern . in the preferred embodiment of the invention , the numerical code is set as the difference between the run count and the threshold count if the following pattern is less than the target pattern , or if there is no following pattern . if the following pattern is greater than the compression sequence , the code is set as a predetermined number , preferably the maximum binary value of the sequence length , minus the difference between the run count and the threshold count .