本页还没有译文
本页 15 段还没译成日本語,下面显示的是英文原文。constructSortFn
还没翻译译自英文(tanstack.com)本页 15 段都还没译
function constructSortFn<TFeatures, TData>(def): CreatedSortFn<TFeatures, TData>;Defined in: features/row-sorting/sortFns.ts:39
Builds a SortFn from a value-level comparator plus an optional
resolveDataValue normalizer.
The sort comparator receives both rows' data values, each already passed
through resolveDataValue when one is defined. Keeping normalization in the
resolver means a variant of an existing sorting function only has to swap
the resolver, not re-implement the comparison.
The definition is attached to the returned function, so a variant can be created by spreading a built-in sorting function and overriding what differs:
const stripDiacritics = (value: string) =>
value.normalize('NFD').replace(/\p{Diacritic}/gu, '')
const alphanumericIgnoreDiacritics = constructSortFn({
...sortFn_alphanumeric,
resolveDataValue: (value) =>
stripDiacritics(sortFn_alphanumeric.resolveDataValue!(value)),
})Type Parameters
TFeatures
TFeatures extends TableFeatures = any
TData
TData extends RowData = any
Parameters
def
SortFnDef<TFeatures, TData>
Returns
CreatedSortFn<TFeatures, TData>
AI 翻译查看英文原文