<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 12.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/Table/init(selection:sortOrder:columns:rows:)-2wf4k",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI5TableV9selection9sortOrder7columns4rowsACyxq_q0_GAA7BindingVy2IDQzSgG_AJySayqd__GGq0_yXEq_yXEtc10Foundation14SortComparatorRd__8ComparedQyd__0C8RowValueRt0_lufc"
  },
  "title" : "init(selection:sortOrder:columns:rows:)"
}
-->

# init(selection:sortOrder:columns:rows:)

Creates a sortable table with the given columns and rows that supports
selecting zero or one row.

```
nonisolated init<Sort>(selection: Binding<Value.ID?>, sortOrder: Binding<[Sort]>, @TableColumnBuilder<Value, Sort> columns: () -> Columns, @TableRowBuilder<Value> rows: () -> Rows) where Sort : SortComparator, Columns.TableRowValue == Sort.Compared
```

## Parameters

`selection`

A binding to the optional selected row ID.

`sortOrder`

A binding to the ordered sorting of columns.

`columns`

The columns to display in the table.

`rows`

The rows to display in the table.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)