G.SortedPairsByMemberValue

From GMod Wiki

Jump to: navigation, search
Warning 64.pngThis page needs to be edited as it contains information that is unclear or incorrect. Improvement can be discussed on the talk page. Find more pages that need work here.
Details: None given.


Function
Syntax SortedPairsByMemberValue( Table table, Var index, Boolean reverse )
Where is this used?
Description:
Generates an iterator for traversing tables in subtable value order
Returns: Function iterator, Table state
Part of Library: Global Functions
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=G.SortedPairsByMemberValue]G.SortedPairsByMemberValue [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionIterate through a table in order of its subtables' values
Used onNewerShared.png
Code
local TestTable = {
    FirstPlayer = {Name = "Thomas"},
    SecondPlayer = {Name = "Richard"},
    ThirdPlayer = {Name = "Harold"}
}
 
for k,v in SortedPairsByValue(TestTable, "Name") do
    print(k,v.Name)
end
OutputThirdPlayer Harold

SecondPlayer Richard

FirstPlayer Thomas


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox