function [w,I] = greedyCoupling(w,I)

% keyboard
[~,is] = sort(sum(w,2),'descend');
w = w(is,:);
I = I(is,:);
[M,N] = size(w);

I2 = reshape(1:M,M/2,2);
I2(:,2) = flipud(I2(:,2));
I2 = reshape(I2',1,M);

w = w(I2,:)';
I = I(I2,:)';

w = reshape(w,2*N,M/2)';
I = reshape(I,2*N,M/2)';

