Matlab, 119134 bytes
I just tried my best to shorten my code in Matlab, like telegraphing it.
function V=z(M) [m,n]=size(M); a=(1:m)'*ones(1,n); b=ones(m,1)*(1:n); A=a+b-1; B=a-b; C=(A.^2+(-1).^A.*B+1); [~,I]=sort(C(:)); V=M(:); V=V(I)'; Notes:
Mis anm×nmatrix.aandbare both matrices same size ofM, each row ofaconsists of numbers equal to its row number, while each column ofbis equal to its column number. Thus,a+bis a matrix whose element equals to sum of its row and column number, i.e.,matrix(p,q)=p+q.- Thus,
A(p,q)=p+q-1; andB(p,q)=p-q. Cis mathematically stated as equation below.
with the equation, a zigzagifiedly increasing matrix can be made like shown below.
C = 1 2 6 7 3 5 8 14 4 9 13 18 10 12 19 25
Cindicates the order of elements of M in zigzagified results. Then,[~,I]=sort(C(:));returns the order, i.e.,I, thus,V=V(I)'is the result.