How to shuffle questions?

How do i randomly generate this question? any idea??

local M = { { question = "9 + 8", image = nil, answer = 2, answers = { "11", "17", "12", }, }, { question = "7 + 6", image = nil, answer = 3, answers = { "10", "12", "13", }, }, { question = "8 + 8", image = nil, answer = 2, answers = { "15", "16", "17", }, }, { question = "9 + 9", image = nil, answer = 3, answers = { "17", "19", "18", }, }, { question = "7 + 5", image = nil, answer = 1, answers = { "12", "16", "13", }, }, return M

[lua]

local function shuffle(t)

    local rand = math.random

    for i = #t, 2, -1 do

        local j = rand(i)

        t[i], t[j] = t[j], t[i]

    end

end

m = shuffle(m)

[/lua]

Furthermore are you really going to hard-code all these maths questions?

You could just generate them all dynamically, that way you could have basically an unlimited number of questions.

I would write a function that generates a table also, it would be much more practical.

[lua]

local function shuffle(t)

    local rand = math.random

    for i = #t, 2, -1 do

        local j = rand(i)

        t[i], t[j] = t[j], t[i]

    end

end

m = shuffle(m)

[/lua]

Furthermore are you really going to hard-code all these maths questions?

You could just generate them all dynamically, that way you could have basically an unlimited number of questions.

I would write a function that generates a table also, it would be much more practical.