Skip to content
Dennis Corvers edited this page Oct 23, 2026 · 2 revisions

Enumerable:sort

Sorts values in ascending order using Lua's < comparison.

Syntax

ordered = source:sort()

Parameters

This method has no parameters.

Returns

A deferred Enumerable that buffers and sorts the source values when enumerated.

Remarks

Values must be comparable with Lua's < operator. Sorting is performed when the result is enumerated, not when sort is called. order is an alias.

Example

local orderedNames = LuaQ.from({ "Bryn", "Ada", "Cato" })
    :sort()
    :toTable()
-- { "Ada", "Bryn", "Cato" }

See also

SortDescending · SortBy · ThenBy · Functions

Clone this wiki locally