Skip to content

SortModel

Defined in: api/node/typescript/models.ts:604 ↗

SortModel acts as an adapter model for a given source model by sorting all its rows according to the order given by compareFunction.

const source = new ArrayModel(["lorem", "ipsum", "dolor"]);
const sorted = new SortModel(source, (a, b) => a.localeCompare(b));
// prints dolor, ipsum, lorem
for (const x of sorted) {
console.log(x);
}
js
  • NativeAdapterModel<T>

T

new SortModel<T>(sourceModel, compareFunction): SortModel<T>

Defined in: api/node/typescript/models.ts:620 ↗

Constructs a new SortModel that provides a sorted view on the given sourceModel by applying the order given by compareFunction.

Model<T>

the wrapped model.

(a, b) => number

compares two rows the same way the callback passed to Array.prototype.sort does. It must not modify sourceModel or read this SortModel, and it must define a consistent total order. An inconsistent comparator such as (a, b) => a > b makes reading the model fail with an error.

SortModel<T>

NativeAdapterModel<T>.constructor

readonly sourceModel: Model<T>

Defined in: api/node/typescript/models.ts:608 ↗

The source model that this SortModel sorts rows from.

get [nativeModelKey](): NativeModel | undefined

Defined in: api/node/typescript/models.ts:424 ↗

NativeModel | undefined

NativeAdapterModel.[nativeModelKey]

[iterator](): Iterator<T>

Defined in: api/node/typescript/models.ts:195 ↗

Iterator<T>

NativeAdapterModel.[iterator]


filter(filterFunction): FilterModel<T>

Defined in: api/node/typescript/models.ts:118 ↗

Returns a new Model that only contains the rows of this model for which filterFunction returns true.

(data) => boolean

returns true if a row should be visible.

FilterModel<T>

a new FilterModel that wraps the current model.

NativeAdapterModel.filter


insertRow(_index, _data): void

Defined in: api/node/typescript/models.ts:191 ↗

Implementations of this function must add a row at the specified index, pushing all next rows to the right. Throws when the model rejects the modification; the default implementation always throws.

number

index of the row to insert.

T

new data item to store in a new row.

void

NativeAdapterModel.insertRow


map<U>(mapFunction): MapModel<T, U>

Defined in: api/node/typescript/models.ts:108 ↗

Returns a new Model where all elements are mapped by the function mapFunction.

U

(data) => U

maps the data from T to U.

MapModel<T, U>

a new MapModel that wraps the current model.

NativeAdapterModel.map


pushRow(data): void

Defined in: api/node/typescript/models.ts:169 ↗

Adds a line to the model with the provided data. Throws when the model rejects the modification. The default implementation calls Model.insertRow with the row count.

T

new data item to store in a new row.

void

NativeAdapterModel.pushRow


removeRow(_index): void

Defined in: api/node/typescript/models.ts:179 ↗

Implementations of this function must remove the row at the specified index. Throws when the model rejects the modification; the default implementation always throws.

number

index of the row to remove.

void

NativeAdapterModel.removeRow


reset(): void

Defined in: api/node/typescript/models.ts:642 ↗

Re-applies the sort order on the rows of the source model. Use this if the compare function depends on state external to the source model and that state has changed.

void


reverse(): ReverseModel<T>

Defined in: api/node/typescript/models.ts:137 ↗

Returns a new Model with the same rows as this model, in reverse order.

ReverseModel<T>

a new ReverseModel that wraps the current model.

NativeAdapterModel.reverse


rowCount(): number

Defined in: api/node/typescript/models.ts:436 ↗

Returns the number of entries in the model.

number

NativeAdapterModel.rowCount


rowData(row): T | undefined

Defined in: api/node/typescript/models.ts:445 ↗

Returns the data at the specified row.

number

index in range 0..(rowCount() - 1).

T | undefined

undefined if row is out of range otherwise the data.

NativeAdapterModel.rowData


setRowData(row, data): void

Defined in: api/node/typescript/models.ts:455 ↗

Stores the given data in the source model at the row that corresponds to the given row index.

number

index in range 0..(rowCount() - 1).

T

new data item to store on the given row index.

void

NativeAdapterModel.setRowData


sort(compareFunction): SortModel<T>

Defined in: api/node/typescript/models.ts:129 ↗

Returns a new Model with the same rows as this model, ordered according to compareFunction.

(a, b) => number

compares two rows the same way the callback passed to Array.prototype.sort does.

SortModel<T>

a new SortModel that wraps the current model.

NativeAdapterModel.sort


unsortedRow(sortedRow): number | undefined

Defined in: api/node/typescript/models.ts:652 ↗

Given a sortedRow index into this SortModel, returns the corresponding row index in the source model.

number

index in range 0..(rowCount() - 1).

number | undefined

undefined if sortedRow is out of range otherwise the source row index.


© 2026 SixtyFPS GmbH