Homeworld 2 : Functionsort
Karos Graveyard ::
Function Reference :: Scope Reference :: Variable Reference
sort(<tTable> [, <Comp>])

Description (from LUA 4 Manual: 6.1 Basic Functions
"Sorts table elements in a given order, in-place, from <tTable>[1] to <tTable>[n], where n is the result of getn(<tTable>) (see Section 6.1). If <Comp> is given, then it must be a function that receives two table elements, and returns true (that is, a value different from nil) 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)."

Example
names = {"Peter", "Paul", "Mary"}
grades = {Mary = 10, Paul = 7, Peter = 8}
sort(names) --> Mary, Paul, Peter
sort(names, function (n1, n2) return grades[n1] > grades[n2] end) --> Mary, Peter, Paul

Arguments
<tTable>: the table to sort.
<Comp>: Not really sure what this is. -Mikail. Example taken from 'Programming in lua' to show how the 'comp' function works; it is useful to sort complex tables or a table in accordance to another table with common entries. -Sun Tzu

Related Functions
:: ::
Hide Download Bar
Ctrl + Shift + Z = Show/Hide Download Bar
Downloads
Download Manager (S3)
Clear
Left Click: Clear All Finished
Right Click: Undo last clear
100%
Download History
Download list is empty
FunctionSobGroup_UnRestrictBuildOption.html
100%
00:00
582 KB
2.17 MB/s
FunctionSobGroup_UnRestrictBuildOption.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_UnRestrictBuildOption.html
Status:
582 KB / 582 KB ( 2.17 MB/s )
File Size:
582 KB
Virus scan:
Time Start:
2019.08.21 - 11:30:21
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
2.07 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop
FunctionSobGroup_UnderAttack.html
100%
00:00
581 KB
2.62 MB/s
FunctionSobGroup_UnderAttack.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_UnderAttack.html
Status:
581 KB / 581 KB ( 2.62 MB/s )
File Size:
581 KB
Virus scan:
Time Start:
2019.08.21 - 11:30:34
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
2.47 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop
FunctionSobGroup_TakeDamage.html
100%
00:00
513 KB
2.26 MB/s
FunctionSobGroup_TakeDamage.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_TakeDamage.html
Status:
513 KB / 513 KB ( 2.26 MB/s )
File Size:
513 KB
Virus scan:
Time Start:
2019.08.21 - 11:31:11
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
2.14 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop
FunctionSobGroup_SwitchOwner.html
100%
00:00
514 KB
2.34 MB/s
FunctionSobGroup_SwitchOwner.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_SwitchOwner.html
Status:
514 KB / 514 KB ( 2.34 MB/s )
File Size:
514 KB
Virus scan:
Time Start:
2019.08.21 - 11:31:22
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
2.21 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop
FunctionSobGroup_SubSystemSelected.html
100%
00:00
513 KB
2.47 MB/s
FunctionSobGroup_SubSystemSelected.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_SubSystemSelected.html
Status:
513 KB / 513 KB ( 2.47 MB/s )
File Size:
513 KB
Virus scan:
Time Start:
2019.08.21 - 11:31:32
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
2.33 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop
FunctionSobGroup_Stop.html
100%
00:00
539 KB
2.35 MB/s
FunctionSobGroup_Stop.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_Stop.html
Status:
539 KB / 539 KB ( 2.35 MB/s )
File Size:
539 KB
Virus scan:
Time Start:
2019.08.21 - 11:31:59
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
2.24 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop
FunctionSobGroup_SpawnNewShipInSobGroup.html
100%
00:00
540 KB
2.64 MB/s
FunctionSobGroup_SpawnNewShipInSobGroup.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_SpawnNewShipInSobGroup.html
Status:
540 KB / 540 KB ( 2.64 MB/s )
File Size:
540 KB
Virus scan:
Time Start:
2019.08.21 - 11:32:12
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
2.50 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop
FunctionSobGroup_Spawn.html
100%
00:00
539 KB
2.77 MB/s
FunctionSobGroup_Spawn.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_Spawn.html
Status:
539 KB / 539 KB ( 2.77 MB/s )
File Size:
539 KB
Virus scan:
Time Start:
2019.08.21 - 11:32:22
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
2.62 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop
FunctionSobGroup_SobGroupAdd.html
100%
00:00
539 KB
1.10 MB/s
FunctionSobGroup_SobGroupAdd.html
Source:
From:
To:
G:\HWRMResources\tutorials\hw2wiki.net\Functions_StandAlone\FunctionSobGroup_SobGroupAdd.html
Status:
539 KB / 539 KB ( 1.10 MB/s )
File Size:
539 KB
Virus scan:
Time Start:
2019.08.21 - 11:32:31
Time to Complete:
<00:01
Time Left:
00:00
Percent Done:
100%
Average Speed:
1.08 MB/s
mouse double click: download pause/resume
mouse middle click: download cancel
mouse double click: open file
mouse double click + Ctrl: open dir
mouse middle click: delete from list
mouse middle click + Ctrl: delete from system
press mouse button + Ctrl: drag & drop