table.sort with Comparators
Sort tables with custom comparator functions and stable sort strategies.
What Is table.sort?
table.sort sorts a table in-place using a comparison function. Without a comparator it uses the < operator.
Default Ascending Sort
Call table.sort(t) on a table of numbers or strings to sort ascending.
local nums = {5, 2, 8, 1, 9}
table.sort(nums)
for _, v in ipairs(nums) do print(v) endAll lessons in this course
- table.sort with Comparators
- table.concat and table.move
- Deep Copy and Shallow Copy
- Transforming Tables: map, filter, reduce