Skip to content

ca: List users in an always deterministic manner

Previously a HashMap was used and that resulted in seemingly random order of users in user list command.

Using BTreeMap and implementing PartialOrd and Ord for Usercerts makes the list appear the same on each invocation.

I'm not 100% sure this is a right implementation. Alternatives considered:

  • using a wrapper struct thus Usercert doesn't need to impl PartialOrd and Ord, but this complicates implementation,
  • sorting keys higher up in the stack thus usercerts_check_certifications would still return HashMap that we'd pick the users from on render time.

Sadly BTreeMap doesn't accept comparator so this is not as straightforward as I'd like it to be :(

Merge request reports