Garry's Mod Wiki

table.Reverse

  table table.Reverse( table tbl )

Description

Returns a reversed copy of a sequential table. Any non-sequential and non-numeric keyvalue pairs will not be copied.

Arguments

1 table tbl
Table to reverse.

Returns

1 table
A reversed copy of the table.

Example

Creates a table and reverses it.

local tbl = { "One", "Two", "Three", four = 4, [5] = "5" } PrintTable(tbl) print("") PrintTable(table.Reverse(tbl))
Output:
1 = One 2 = Two 3 = Three four = 4 5 = 5 1 = Three 2 = Two 3 = One