Garry's Mod Wiki

table.SortByMember

table.SortByMember( table tab, any memberKey, boolean ascending = false )

Description

Sorts a table by a named member

Arguments

1 table tab
Table to sort
2 any memberKey
The key used to identify the member
3 boolean ascending = false
Whether or not the order should be ascending

Example

Orders a table by a member and prints it

local tab = { {Name = "Bill", Age = 13}, {Name = "Jill", Age = 14}, {Name = "Phil", Age = 8} } table.SortByMember(tab, "Age") for k, v in ipairs(tab) do print(v.Name) end
Output: Jill Bill Phil

Page Links


Special Pages


Wikis

?

Render Time: 42ms

Session 0
DB GetPage 4
Generate Html 16
SaveChanges 8
Render Body 0
Render Sidebar 12