working snippet sort nodes