sort atoms by their id if there is no other distinction when building a tree