Most functions in the table library assume that the table represents an array or a list. For these functions, when we talk about the “length” of a table we mean the result of the length operator.



    Inserts element value at position pos in table, shifting up other elements to open space, if necessary. The default value for is n+1, where n is the length of the table (see ), so that a call table.insert(t,x) inserts x at the end of table t.



    Removes from table the element at position pos, shifting down other elements to close the space, if necessary. Returns the value of the removed element. The default value for pos is n, where is the length of the table, so that a call table.remove(t) removes the last element of table t.


    The sort algorithm is not stable; that is, elements considered equal by the given order may have their relative positions changed by the sort.