Lowest and greatest possible principal when using Principal.compare

I’m inserting principals into a balanced, sorted data structure, using the Principal.compare() comparator defined here motoko-base/src/Principal.mo at 7939b372f44836049b1afeedeee3a90e3741a2ad · dfinity/motoko-base · GitHub

Can someone provide me with the a lowest possible principal, and a greatest possible principal in their textual representations?

My use case is that the data returned by queries on this structure is now larger than 2MB, so I need so break things up and scan through chunks of data at a time.

1 Like

The smallest principal you can encounter is the management canister:

>> Principal::from_slice(&[]).to_string()

And I think this is the largest one as allowed by the spec:

>> Principal::from_slice(&[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,7]).to_string()