Is there an issue with the Legend order for FeatureLayers vs MapService layers?
esri/dijit/Legend
It seems that FeatureLayers are always brought to the top of the legend regardless of the z-Index of the layer.
Maybe AGOL feature layers are treated differently than AGS Feature layers?