table.sortdesc

From GMod Wiki

Jump to: navigation, search
Function
Syntax table.sortdesc( Table table )
Where is this used?
Description:
Sorts a Table into descending alphabetical order.
Returns: nil
Part of Library: Table
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Table.sortdesc]Table.sortdesc [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionSort the values of a Table .
Used onNewerShared.png
Code
local tbl = {"b", "a", "c", "e", "d"}
table.sortdesc( tbl );
 
// Table is now: {"e", "d", "c", "b", "a"}
 
// This function does the same exact thing as this:
table.sort( tbl, function(a, b) return a > b end );
 
OutputPrints a Table in descending alphabetical order into the console.


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox