MV shuffling an array?

is it possible to mix around the order of an array's elements?
for example, if I have:

stack = [1,2,3,4,5]

how would you randomize the order of the elements in the array?

From that discussion thread:
Code:
function shuffleArray(array) {
    for (var i = array.length - 1; i > 0; i--) {
        var j = Math.floor(Math.random() * (i + 1));
        var temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }
}

And if your version of RM supports ES6:
Code:
function shuffleArray(array) {
    for (let i = array.length - 1; i > 0; i--) {
        const j = Math.floor(Math.random() * (i + 1));
        [array[i], array[j]] = [array[j], array[i]];
    }
}
you have my gratitude kind stranger

Original thread: https://forums.rpgmakerweb.com/threads/shuffling-an-array.138709/