Grouping similar adjacent values in a table

Nvm then, Thanks for your time and support!

Also I think table.insert(b[x], a[i]) is cleaner than b[x][#b[x]+1] = a[i]. Though both work fine

It needs to be table.insert(b[x], #b[x]+1, a[i])

1 Like

For some reason it works with just 2 params. 3rd param is needed if you are inserted somewhere other than at the end.

1 Like

Oh ok, did not know that. That will be useful

1 Like

This example on lua.org uses 2. But they do also mention the position param