function [y,Y]=ordena2(x,X,s);

n=length(x(:,1));
L=length(s(1,:));

for k=1:n
    aux(k,:)=x(k,1:L);
end
clear x;
x=aux;
clear aux;

Y=zeros(length(X(:,1,1)),length(X(1,:,1)),n);
for ks=1:n
    corr=0;
    for kx=1:n
        aux=abs(corco(s(ks,:),x(kx,:)));
        if aux >= corr
            corr=aux;
            y(ks,:)=x(kx,:);
            Y(:,:,ks)=X(:,:,kx);
        end
    end
end