# Class: table

### LuxModule: lux_ext

This library provides generic functions for table manipulation. It provides all its functions inside the table table.

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.

## Methods:

### Method overview:

- concat
- copy
- count
- insert
- keyintersection
- maxn
- merge
- print
- remove
- removen
- reverse
- sort

concat (table [, sep [, i [, j] ] ])
  returns: (string)
  Returns table[i]..sep..table[i+1] ... sep..table[j]. The default value for sep is the empty string, the default for i is 1, and the default for j is the length of the table. If i is greater than j, returns the empty string.
copy (table)
  returns: (table)
  makes a simple copy of that table, without respect to refered tables or values inside of that table
count (table)
  returns: (int)
  returns total number of elements via complete traversion
insert (table, [pos,] value)
  returns: (?)
  Inserts element value at position pos in table, shifting up other elements to open space, if necessary. The default value for pos is n+1, where n is the length of the table, so that a call table.insert(t,x) inserts x at the end of table t.
keyintersection (table1,table2,...)
  returns: (table)
  returns a table that is a copy of table1 without keys that are missing in the following tables.
maxn (table)
  returns: (int n)
  Returns the largest positive numerical index of the given table, or zero if the table has no positive numerical indices. (To do its job this function does a linear traversal of the whole table.)
merge (table1,table2,...)
  returns: (table)
  copies all passed tables in one table one after each other, overwriting previous keys with new values.
print (table)
  returns: ()
  prints out all keys and their values - useful for debugging
remove (table [, pos])
  returns: (value)
  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 n is the length of the table, so that a call table.remove(t) removes the last element of table t.
removen (table,int n[, int at)
  returns: (value1, value2, ...)
  removes n elements from. If 'at' is given, the function removes all values from that index on, decrementing the at index with each remove. The order of the removed objects is "normal", which means that it is not changed.
reverse (table)
  returns: (table)
  reverses the indexes of the table (inplace). Returns the same table that was passed.
sort (table [, comp])
  returns: (?)

  Sorts table elements in a given order, in-place, from table[1] to table[n], where n is the length of the table. If comp is given, then it must be a function that receives two table elements, and returns true when the first is less than the second (so that not comp(a[i+1],a[i]) will be true after the sort). If comp is not given, then the standard Lua operator < is used instead.

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