Make layer dialog active using script

When I say sort I mean allow the user or script to determine where in the layer dialog they want a new layer to be placed. I had created a separate topic for it and how I got it to work is to create the new layer as a child of the layer you want it under, then unparent it.