?- L=[_,_,_,_], bagof(t,permutation(L,L),"tttttt").
false, unexpected.
L = [_A,_A,_A,_A].
And in any case, the simplest way to implement setof/3 is:
setof(Templ, G_0, Ts) :-
can_be(list, Ts),
bagof(Templ, G_0, TsB),
sort(TsB, Ts).
It is possible to implement setof/3 with a single sort/2. But for the moment, correctness has priority.