# Ordering Nodes (dot)

**URL:** <https://forum.graphviz.org/t/ordering-nodes-dot/280>\
**Category:** Help\
**Created:** [August 1, 2020, 2:32am UTC](https://forum.graphviz.org/t/ordering-nodes-dot/280 "2020-08-01T02:32:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![milliliter](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@milliliter](https://forum.graphviz.org/u/milliliter)\
**Post date:** [August 1, 2020, 2:32am UTC](https://forum.graphviz.org/t/ordering-nodes-dot/280/1 "2020-08-01T02:32:42Z")

</div>

I’m making trees with dot and I generally want GV to arrange the nodes, but occasionally I want to pick the order of parent or child nodes. This page [Node, Edge and Graph Attributes](https://graphviz.org/doc/info/attrs.html#d:ordering) tells me dot has a node/graph attribute called “ordering” that can be set to “in” or “out,” but there’s no sample code, so I tried every variation I could think of and finally got “ordering=out” to work. I’m putting in a pared-down version of my code; I want to swap dotD and orsD where noted.  
[dot verbose=true]  
strict digraph ors {  
node [shape=none]  
ors ordering=out // this puts orso, orsa in order  
ors → orso → arsazGm → {earsOE aersMD}  
earsOE → arsME → ass  
aersMD → orsD  
{dotD orsD} → dodorsD // dotD, orsD are swapped; I want them in this order  
dodorsD → dodoP → dodo  
ors → orsa → ouraG  
{skia ouraG} → skiourosG → sciurusL → scuriolusL → esquirelAN → squirelME → squirrel  
kwon → kuon  
{kuon ouraG} → kunosuraG → cyosuraL → cynosureF → cynosure  
ouraG → ouroG → uroNL → uroE  
subgraph E { rank=same ass dodo squirrel cynosure uroE }  
}  
[/dot]

---

<div class="post-metadata">

**Author:** ![steveroush](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@steveroush](https://forum.graphviz.org/u/steveroush)\
**Post date:** [August 1, 2020, 3:38am UTC](https://forum.graphviz.org/t/ordering-nodes-dot/280/2 "2020-08-01T03:38:00Z")

</div>

I believe that this should do what you want: **dodorsD [ordering=in]**  
But, there is a known bug: [ordering=out is not being obeyed (#1152) · Issues · graphviz / graphviz · GitLab](https://gitlab.com/graphviz/graphviz/-/issues/1152)  
So here is a work-around:  
strict digraph ors {  
node [shape=none]  
ors ordering=out // this puts orso, orsa in order  
ors → orso → arsazGm → {earsOE aersMD}  
earsOE → arsME → ass  
aersMD → orsD  
dodorsD [ordering=in] // I believe this should do it, but there is a bug  
{rank=same dotD → orsD [style=invis]} // dotD, orsD are swapped; I want them in this order  
dotD → dodorsD // dotD, orsD are swapped; I want them in this order  
orsD → dodorsD // dotD, orsD are swapped; I want them in this order  
dodorsD → dodoP → dodo  
ors → orsa → ouraG  
{skia ouraG} → skiourosG → sciurusL → scuriolusL → esquirelAN → squirelME → squirrel  
kwon → kuon  
{kuon ouraG} → kunosuraG → cyosuraL → cynosureF → cynosure  
ouraG → ouroG → uroNL → uroE  
subgraph E { rank=same ass dodo squirrel cynosure uroE }  
}

The invisible edge fixes things:

 ![orderingAgain2](https://global.discourse-cdn.com/graphviz/original/1X/fffbb32c42eab1fc3dc053c953ce26c03bfeb9d0.png)
