# Why sort links in pbnode

**URL:** <https://discuss.ipfs.tech/t/why-sort-links-in-pbnode/3157>\
**Category:** Uncategorized\
**Tags:** ipld, go-ipfs\
**Created:** [June 8, 2018, 4:03am UTC](https://discuss.ipfs.tech/t/why-sort-links-in-pbnode/3157 "2018-06-08T04:03:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ohmygoddess](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/ohmygoddess/32/2453_2.png) [@ohmygoddess](https://discuss.ipfs.tech/u/ohmygoddess)\
**Post date:** [June 8, 2018, 4:03am UTC](https://discuss.ipfs.tech/t/why-sort-links-in-pbnode/3157/1 "2018-06-08T04:03:39Z")

</div>

In the implementation of merkledag, the dag node will be serialized as protobuf node(PBNode). I saw in the code, the links are sorted:

> sort.Stable(LinkSlice(n.links))

But the question is when we add a big file, the file will be split into multiple nodes that linked together. If the order of the links are changed by sorting, how can we make sure get the correct order of file pieces?

Thanks!

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [June 9, 2018, 5:47am UTC](https://discuss.ipfs.tech/t/why-sort-links-in-pbnode/3157/2 "2018-06-09T05:47:05Z")

</div>

We sort by names and chunk nodes aren’t named (so the stable sort doesn’t move anything).

---

<div class="post-metadata">

**Author:** ![ohmygoddess](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/ohmygoddess/32/2453_2.png) [@ohmygoddess](https://discuss.ipfs.tech/u/ohmygoddess)\
**Post date:** [June 10, 2018, 12:03am UTC](https://discuss.ipfs.tech/t/why-sort-links-in-pbnode/3157/3 "2018-06-10T00:03:44Z")

</div>

I got it! Thanks a lot !

---

<div class="post-metadata">

**Author:** ![xmaysonnave](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/xmaysonnave/32/3304_2.png) [@xmaysonnave](https://discuss.ipfs.tech/u/xmaysonnave)\
**Post date:** [March 12, 2021, 10:28am UTC](https://discuss.ipfs.tech/t/why-sort-links-in-pbnode/3157/4 "2021-03-12T10:28:12Z")

</div>

1 - Is there any way to store links without sorting ?  
I try to store links in reverse order and I’m facing this behaviour.  
2 - What are the motivations to sort the links at the server level ?  
Thanks
