API ReferenceGE ExtensionsuivehicleSelector
Vehicle Selector – Tile Sorting
Sorting functions for vehicle selector tiles by various criteria.
Sorting functions for vehicle selector tiles by various criteria.
Overview
ui_vehicleSelector_tileSorting provides comparator functions for sorting vehicle tiles by name, value, weight, power, speed, acceleration, and config type. Used by the tiles module to order items within groups.
Extension path: lua/ge/extensions/ui/vehicleSelector/tileSorting.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
getSortFunction | (sortMode) → fn | Returns the comparator for the given mode. |
sortTiles | (tiles, sortMode) | Sorts a tile array in-place. |
sortGroup | (group, sortMode) | Sorts group.tiles in-place. |
sortByNameButOtherAlwaysLast | (a, b) → bool | Name sort, "Other..." always last. |
sortByValue | (a, b) → bool | Sort by Value. |
sortByYears | (a, b) → bool | Sort by Years. |
sortByConfigTypeName | (a, b) → bool | Sort by config type order. |
Internals
Sort Modes
| Mode | Sorts By | Direction |
|---|---|---|
Name | Name (alpha) | A→Z, "Other..." last |
Value | Price | Low→High |
Years | Year | Old→New |
Weight | Weight | Light→Heavy |
Top Speed | Top speed | Slow→Fast |
Power | Power | Low→High |
Weight/Power | Weight÷Power ratio | Best→Worst |
0-60 mph | 0-60 time | Best→Worst (reversed) |
0-100 km/h | 0-100 time | Best→Worst (reversed) |
Config Type | Predefined order | Factory→Other |
Config Type Order
Factory(1) → Service(2) → Race(3) → Drift(4) → Rally(5)
→ Police(6) → Custom(7) → Powerglow(8) → Other(9)Tie-Breaking
All sort functions fall back to sortByNameButOtherAlwaysLast on equal values, with "Other..." items always sorted last.
How It Works
- The tiles module calls
sortTiles(tiles, sortMode)after building tiles for a group. getSortFunctionlooks up the comparator from thesortFunctionstable.table.sortis called with the comparator.
Lua Examples
local tileSorting = require('/lua/ge/extensions/ui/vehicleSelector/tileSorting')
-- Sort tiles by value
tileSorting.sortTiles(myTiles, "Value")
-- Get comparator for custom sorting
local cmp = tileSorting.getSortFunction("Power")
table.sort(myList, cmp)Additional Exports
The following exports are available but not yet documented in detail:
M.getSortFunctionM.sortByConfigTypeNameM.sortByNameButOtherAlwaysLastM.sortByValueM.sortByYearsM.sortGroupM.sortTiles