I am looking for a way to get all possible combination with an array intake so if we had [1,2,3]
it would return
[1,1,1],[1,1,2],[1,1,3],[1,2,2],[1,2,3],[1,3,3],[2,2,2],[2,2,3],[2,3,3],[3,3,3].
I have looked at several other posts such as this one here: https://stackoverflow.com/a/9960925/1328107 but they all seem to stop short of all combinations, ie
[ 1, 2, 3 ], [ 1, 3, 2 ],[ 2, 1, 3 ], [ 2, 3, 1 ], [ 3, 1, 2 ], [ 3, 2, 1 ].
Any help would be greatly appreciated.