cmpf(x,y) = {
	if (x==y,
			return (0),
			for (e=1, oo,
				my (d=if (x, exponent(x^e), -1)-if (y, exponent(y^e), -1));
				if (d,
					return (-(-1)^e * d);
				);
			);
	);
}

n=-1
apply (v -> print (n++ " " v), vecsort([0..2^13-1], cmpf))

quit