This library provides generic functions for table manipulation. It provides all its functions inside the global table variable. 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.
Description: Given a list where all elements are strings or numbers, returns the string list[i]..sep..list[i+1] ... sep..list[j]. The default value for sep is the empty string, the default for i is 1, and the default for j is #list. If i is greater than j, returns the empty string.
Description: Iterates over the provided table, passing the key and value of each iteration over to the provided function.
Description: This is similar to table.foreach() except that index-value pairs are passed, not key-value pairs.
Description: Returns the number of elements in the table passed
Description: Appends the provided value to the end of the table.
Description: Removes from list the element at position pos, returning the value of the removed element. When pos is an integer between 1 and #list, it shifts down the elements list[pos+1], list[pos+2], ..., list[#list] and erases element list[#list]; The index pos can also be 0 when #list is 0, or #list + 1; in those cases, the function erases the element list[pos].
Description: Sorts list elements in a given order, in-place, from list to list[#list]. If comp is given, then it must be a function that receives two list elements and returns true when the first element must come before the second in the final order (so that not comp(list[i+1],list[i]) will be true after the sort). If comp is not given, then the standard Lua operator [less than] is used instead.