I am trying to switch numbers between rows

here is the thing

there are 8! (40320) cases that i need to make arraying numbers in total

E.g., (8*7*6*5*4*3*2*1) : (0, 1, 2, 3, 4, 5, 6, 7) (1,0,2,3,4,5,6,7)(1,2,0,3,4,5,6,7) (1,2,3,0,4,5,6,7) .... (7,6,5,4,3,2,1,0)

so i am going to create 40320 fields and trying to put number in it.

I was thinking that i could use Random number generator but it returns duplicate number in rows and also it might have a chance to have duplicate fields.

Are there any ways that i can do this easy way using field calculator's code block?

I can help with the numbers, but you aren't going to get that number of fields.

What you want is a permutation. two examples follow... I have printed one example out and just given the length of the 2nd. I strongly don't recommend that you print it out... at least on paper

EDIT fixed line 2 Nov 10 to read ..... range(3), 3)]