# => │ 0 │ CNAME │ file │ 15 B │ 9 months ago │
# => │ 1 │ CONTRIBUTING.md │ file │ 4.3 KiB │ 9 hours ago │
# => │ 2 │ LICENSE │ file │ 1.0 KiB │ 9 months ago │
# => │ ---> │ README.md │ file │ 2.2 KiB │ 3 weeks ago │
# => │ 4 │ assets │ dir │ 4.0 KiB │ 9 months ago │
# => ╰──────┴─────────────────┴──────┴─────────┴──────────────╯
ls | upsert 3.index { "--->" } | first 5 | describe
# => list<any> (stream)
ls | upsert 3.index { "--->" } | select index name
# Error: cannot find column 'index'
ls | upsert 3.index { "--->" } | select index? name | first 5
# => ╭──────┬─────────────────╮
# => │ # │ name │
# => ├──────┼─────────────────┤
# => │ │ CNAME │
# => │ │ CONTRIBUTING.md │
# => │ │ LICENSE │
# => │ ---> │ README.md │
# => │ │ assets │
# => ╰──────┴─────────────────╯
```
- As demonstrated in the example above, any rows (records) in the table without an `index` key will continue to display the internal representation.
#### Additional Index Examples
##### Convert # to Index
A useful pattern for converting an internal `#` into an index for all rows, while maintaining the original numbering, is:
```nu
ls | enumerate | flatten
```
While the results _look_ the same, the `index` is now decoupled from the internal cell-path. For example:
```nu
ls | enumerate | flatten | sort-by modified | first 5
# => ╭────┬──────────────┬──────┬─────────┬──────────────╮
# => │ # │ name │ type │ size │ modified │
# => ├────┼──────────────┼──────┼─────────┼──────────────┤
# => │ 0 │ CNAME │ file │ 15 B │ 9 months ago │
# => │ 2 │ LICENSE │ file │ 1.0 KiB │ 9 months ago │
# => │ 4 │ assets │ dir │ 4.0 KiB │ 9 months ago │
# => │ 17 │ lefthook.yml │ file │ 1.1 KiB │ 9 months ago │
# => │ 24 │ snippets │ dir │ 4.0 KiB │ 9 months ago │
# => ╰────┴──────────────┴──────┴─────────┴──────────────╯
ls | enumerate | flatten | sort-by modified | select 4
# => ╭────┬──────────┬──────┬─────────┬──────────────╮
# => │ # │ name │ type │ size │ modified │
# => ├────┼──────────┼──────┼─────────┼──────────────┤
# => │ 24 │ snippets │ dir │ 4.0 KiB │ 9 months ago │
# => ╰────┴──────────┴──────┴─────────┴──────────────╯