diff --git a/src/rle.rs b/src/rle.rs index e3e6cc5..662e69b 100644 --- a/src/rle.rs +++ b/src/rle.rs @@ -116,7 +116,10 @@ impl BlockQ4KRle { /// /// The `d`, `dmin`, and `scales` fields are always copied verbatim. pub fn encode(block: &BlockQ4K) -> BlockQ4KRle { - let raw = &block.qs; + let mut raw = Vec::from(&block.qs); + + // Sort the raw numbers + raw.sort(); // Scan the 128-byte raw payload for runs of equal bytes. let mut pairs: Vec<(u8, u8)> = Vec::with_capacity(64);