I'm looking for a
simple algorithm that will give me every possible order of an array
regardless of size.
For instance: An array of three elements [ 1, 2, 3 ] will give me [ 1, 2, 3 ], [ 1, 3, 2 ], [ 2, 1, 3 ], [ 2, 3, 1 ], [ 3, 1, 2 ] and [ 3, 2, 1 ]. It seems like there should be a pretty simple mathematical solution for this but I can't seem to figure it out or find it anywhere.