Overview
Sorting changes the order of items in a table. This demo is about programming data you provide; the Adopt Me theme is only a familiar context for sample pet or item records.
This Adopt Me resource is a manual planning or learning aid. It does not connect to a Roblox account, inspect live game state or automate gameplay.
What this resource covers
- Sample records
- Sort key
- Comparator function
- Before-and-after order
How to use it
- Inspect the sample records and choose the field to sort by.
- Read the comparator passed to `table.sort`.
- Run the example and inspect the new order.
- Test equal values and missing fields before adapting it.
Worked example
If records contain a `name` field, a comparator can return `a.name < b.name` to sort alphabetically. For numeric fields, compare numbers rather than their text representations.
Limitations and verification
The demo does not sort or access a live Adopt Me inventory. `table.sort` modifies the table in place, and a comparator must define a consistent ordering for the data.