diff --git a/src/component/cyfs-base/src/codec/raw/raw_types.rs b/src/component/cyfs-base/src/codec/raw/raw_types.rs index f18bbeed7..9b028ad74 100644 --- a/src/component/cyfs-base/src/codec/raw/raw_types.rs +++ b/src/component/cyfs-base/src/codec/raw/raw_types.rs @@ -740,7 +740,7 @@ impl<'de, T: RawEncode + RawDecode<'de>> RawDecode<'de> for Vec { // HashSet -impl RawEncode for HashSet { +impl RawEncode for HashSet { fn raw_measure(&self, purpose: &Option) -> BuckyResult { let ulen = USize(self.len()); let mut bytes = ulen.raw_measure(purpose).unwrap(); @@ -757,7 +757,12 @@ impl RawEncode for HashSet { ) -> BuckyResult<&'a mut [u8]> { let ulen = USize(self.len()); let mut buf = ulen.raw_encode(buf, purpose)?; - for e in self { + + // stable sort + let mut values: Vec<&T> = self.iter().collect(); + values.sort(); + + for e in values { buf = e.raw_encode(buf, purpose)?; } Ok(buf)