示例工程 08-table-structure
08-table-structure/04-iteration-order/README.md
# 04 · iteration-order
**演示**:`pairs` 的键顺序不保证;排序后集合才稳定。
**运行时**:`lua54`、`luajit`。
**运行**:
```sh
.tools/bin/lua54 scripts/run-example.lua examples/08-table-structure/04-iteration-order
.tools/bin/lua54 scripts/test-example.lua examples/08-table-structure/04-iteration-order
```
**预期输出**(lua 5.4.9 / macOS arm64;`keys` 顺序可能不同):
```text
sorted=alpha,beta,gamma
```
**看点**:不要用 `pairs` 顺序做稳定输出或比较。
**注意**:需要顺序时显式排序;`ipairs` 只适用于序列。