I am implementing a Merkle tree and am considering using either of the two options.
The first one is sorting only by leaves. This one makes sense to me since you would like to have the same input every time you are constructing a tree from the data, that might not arrive sorted by default.
CAB / \ CA \ / \ \ C A B / \ / \ / \ 1 2 3 4 5 6
The second one is sorting by leaves and pairs, which means that after sorting the leaves, you also sort all the pairs after hashing them, however I’m not entirely sure about the benefits of this implementation (if any).
ACB / \ AC \ / \ \ C A B / \ / \ / \ 1 2 3 4 5 6
I have seen these implementations of Merkle trees in the past but am not sure about their benefits. So why choose one over the other?