The order of attributes, including namespace declaration attributes, in a direct element constructor is not significant. But while playing around I found that it makes a difference with BaseX for expressions that are embedded in an attribute.
So these two constructors produce different results, but I think it should be the same:
basex -q"<e xmlns='A'><e xmlns='B' a='{namespace-uri-for-prefix((), <e/>)}'/></e>"
basex -q"<e xmlns='A'><e a='{namespace-uri-for-prefix((), <e/>)}' xmlns='B'/></e>"
Tested on BaseX 8.4.1.
Best regards Gunther