API ReferenceGE ExtensionsuigameplaySelector
Tile Sorting
Centralized sorting module for gameplay selector tiles - supports name, system, date, and automatic multi-criteria sorting.
Centralized sorting module for gameplay selector tiles - supports name, system, date, and automatic multi-criteria sorting.
Overview
tileSorting provides sort functions and utilities for ordering gameplay tiles within groups. It handles complex sorting rules including auxiliary/career item ordering, system priority, and UI-to-internal mode mapping.
Module path: lua/ge/extensions/ui/gameplaySelector/tileSorting.lua (loaded via require)
Exports (M)
| Function | Signature | Description |
|---|---|---|
sortTiles | (tiles, sortMode) | Sorts a tile list in-place by the given mode. |
sortTilesFromUIValue | (tiles, uiSortValue) | Sorts using a UI dropdown value (auto-converts). |
getSortFunction | (sortMode) | Returns the comparator function for a mode. |
isValidSortMode | (sortMode) | Returns true if the mode is recognized. |
convertUIValueToSortMode | (uiValue) | Maps UI values to internal sort modes. |
sortGroup | (group, sortMode) | Sorts group.tiles in-place. |
sortByNameButOtherAlwaysLast | (a, b) | Alphabetical, "Other..." always last. |
sortBySystem | (a, b) | By system order, then name. |
sortByGameplayAutomatic | (a, b) | Multi-criteria gameplay sorting. |
sortByDate | (a, b) | Newest first, no-date items last. |
Constants
| Constant | Description |
|---|---|
M.SYSTEM_ORDER | Priority map: Freeroam=1, Challenges=2, Scenarios=3, Campaigns=4 |
M.UI_TO_SORT_MODE | Maps UI values to internal: automatic→GameplayAutomatic, name→Name, date→Date |
Data Fields
| Field | Description |
|---|---|
M.VALID_SORT_MODES | Table of valid sort mode identifiers. |
M.SORT_MODE_TO_UI | Map from sort mode identifiers to UI display strings. |
Internals
GameplayAutomatic Sort Order
The multi-criteria sort applies in this priority:
- Clustered items first - tiles from clustering sort by name
- System order - Freeroam → Challenges → Scenarios → Campaigns → Other
- Non-auxiliary before auxiliary - debug content sorts last
- Challenges-specific: non-career before career, then by
orderproperty - Fallback: by
orderproperty, then alphabetically
local function sortByGameplayAutomatic(a, b)
local clusteredResult = compareClusteredStatus(a, b)
if clusteredResult ~= nil then return clusteredResult end
local aOrder = M.SYSTEM_ORDER[a.system] or 999
local bOrder = M.SYSTEM_ORDER[b.system] or 999
if aOrder ~= bOrder then return aOrder < bOrder end
local auxResult = compareAuxiliaryStatus(a, b)
if auxResult ~= nil then return auxResult end
-- ...continues with career/order/name comparisons
endDate Sorting
Sorts newest first. Items without dates sort to the end:
local function sortByDate(a, b)
if a.date == b.date then return sortByNameButOtherAlwaysLast(a, b) end
if not a.date then return false end
if not b.date then return true end
return a.date > b.date
endHow It Works
- The tiles module calls
sortTilesFromUIValue(tiles, displayData.sorting) - UI value
"automatic"maps to internal"GameplayAutomatic" - The multi-criteria sort applies system order, auxiliary status, and per-system rules
table.sortis called with the selected comparator function- Groups use
sortGroupfor convenient in-place sorting
Additional Exports
The following exports are available but not yet documented in detail:
M.convertUIValueToSortModeM.getSortFunctionM.isValidSortModeM.sortByDateM.sortByGameplayAutomaticM.sortByNameButOtherAlwaysLastM.sortBySystemM.sortGroupM.sortTilesM.sortTilesFromUIValue