Generate all combinations of given list of elements, sorted Make a code that takes a list and a number as input, and generates all possible combinations with the length of the number. For example, with the list {0,1} and the number 2:

00
01
10
11


Your program doesn't have to expect characters twice or more often in the list, such as {0,0,0,0,0,1,1,5,5}

Make sure you print the combinations out sorted, in the order of the list:

With the list {0,1} and the number 5 (generated by some of my code, which is a way too long to win):

00000
00001
00010
00011
00100
00101
00110
00111
01000
01001
01010
01011
01100
01101
01110
01111
10000
10001
10010
10011
10100
10101
10110
10111
11000
11001
11010
11011
11100
11101
11110
11111


But with the list {1,0} and the number 2:

11
10
01
00


As you can see, reversed list means reversed order.

Take a look at the structure, it's like a tree.

This is code-golf, so the shortest code in bytes wins!
Jelly, 1 byte

ṗ


TryItOnline

Cartesian power built-in atom, as a dyadic link with left argument the items and right argument the count, or as a full program with first argument the items and second argument the count.