mirror of
https://github.com/Keyslam-Group/Concord.git
synced 2025-09-03 21:03:54 -04:00
parent
a45d89457b
commit
89eab3fb72
1 changed files with 14 additions and 0 deletions
|
@ -94,6 +94,20 @@ function List:indexOf(obj)
|
||||||
return self[obj]
|
return self[obj]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Sorts the List in place, using the order function.
|
||||||
|
-- The order function is passed to table.sort internally so documentation on table.sort can be used as reference.
|
||||||
|
-- @param order Function that takes two Entities (a and b) and returns true if a should go before than b.
|
||||||
|
-- @treturn List self
|
||||||
|
function List:sort(order)
|
||||||
|
table.sort(self, order)
|
||||||
|
|
||||||
|
for key, obj in ipairs(self) do
|
||||||
|
self[obj] = key
|
||||||
|
end
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
return setmetatable(List, {
|
return setmetatable(List, {
|
||||||
__call = function()
|
__call = function()
|
||||||
return List.new()
|
return List.new()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue