# Lowest and greatest possible principal when using Principal.compare

**URL:** <https://forum.dfinity.org/t/lowest-and-greatest-possible-principal-when-using-principal-compare/27500>\
**Category:** Language Support\
**Tags:** Motoko\
**Created:** [February 11, 2024, 7:45pm UTC](https://forum.dfinity.org/t/lowest-and-greatest-possible-principal-when-using-principal-compare/27500 "2024-02-11T19:45:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![icme](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icme/32/4327_2.png) [@icme](https://forum.dfinity.org/u/icme)\
**Post date:** [February 11, 2024, 7:45pm UTC](https://forum.dfinity.org/t/lowest-and-greatest-possible-principal-when-using-principal-compare/27500/1 "2024-02-11T19:45:51Z")

</div>

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](https://github.com/dfinity/motoko-base/blob/7939b372f44836049b1afeedeee3a90e3741a2ad/src/Principal.mo#L159)

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.

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [February 12, 2024, 10:14am UTC](https://forum.dfinity.org/t/lowest-and-greatest-possible-principal-when-using-principal-compare/27500/2 "2024-02-12T10:14:36Z")

</div>

The smallest principal you can encounter is the management canister:

```auto
>> Principal::from_slice(&[]).to_string()
"aaaaa-aa"

```

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

```auto
>> 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()
"f7qpl-vh777-77777-77777-77777-77777-77777-77777-77777-77777-7qo"

```
