Matlab, 100 bytes
I just tried my best to shorten my code in Matlab, like telegraphing it.
[m,n]=size(M); a=ones(n,1)*(1:m); A=a'+a-1;B=a'-a; C=A.^2+(-1).^A.*B+1; [~,I]=sort(C(:)); V=M(:);V=V(I)'; Notes:
Mis anm×nmatrix.ais a matrix same size ofM, each row consists of numbers equal to row number. Thus,a+a'(transpose ofa) is a matrix whose element equals to sum of 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.