{"record":{"id":"48e59f207815170f","repo":"TanStack/table","slug":"sortfn-string-column-columndef-sortfn-for-co","errorCode":null,"errorMessage":"sortFn '${String(column.columnDef.sortFn)}' for column '${column.id}' is not registered","messagePattern":"sortFn '(.+?)' for column '(.+?)' is not registered","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts","lineNumber":234,"sourceCode":"  TFeatures extends TableFeatures,\n  TData extends RowData,\n  TValue extends CellData = CellData,\n>(column: Column_Internal<TFeatures, TData, TValue>): SortFn<TFeatures, TData> {\n  const sortFns: Record<string, SortFn<TFeatures, TData>> | undefined =\n    column.table._rowModelFns.sortFns\n\n  if (isFunction(column.columnDef.sortFn)) {\n    return column.columnDef.sortFn\n  }\n\n  if (column.columnDef.sortFn === 'auto') {\n    return column_getAutoSortFn(column)\n  }\n\n  const sortFn = sortFns?.[column.columnDef.sortFn as string]\n\n  if (process.env.NODE_ENV === 'development' && !sortFn) {\n    console.warn(\n      `sortFn '${String(column.columnDef.sortFn)}' for column '${column.id}' is not registered`,\n    )\n  }\n\n  return sortFn ?? sortFn_basic\n}\n\n/**\n * Applies the next sorting state for this column.\n *\n * The toggle can add, replace, flip, or remove this column's sort entry. Multi\n * sorting respects `enableMultiSort`, `enableMultiRemove`,\n * `maxMultiSortColCount`, and the `multi` argument.\n *\n * @example\n * ```ts\n * column_toggleSorting(column, undefined, true)\n * ```","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/TanStack/table/blob/d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6/packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts#L216-L252","documentation":"When `columnDef.sortFn` is a string, `column_getSortFn` looks it up in the table's `sortFns` registry. If the id is not found, this dev warning fires and the column silently falls back to `sortFn_basic`, so rows still sort but not with the semantics you intended (e.g. locale-aware text or date ordering is lost).","triggerScenarios":"Setting `columnDef.sortFn: 'datetime'` (or any custom id like 'mySort') while that id is absent from `table._rowModelFns.sortFns` — e.g. a typo ('alphnumeric'), a built-in id not included in the installed sorting row-model package, or a custom sort fn that was never added to the `sortFns` registry.","commonSituations":"Typos in sortFn ids; upgrading/downgrading the library and a sort id being renamed or moved to an optional package; forgetting to pass custom sortFns when creating the table with a custom row-model feature set; sharing column defs between tables whose registries differ.","solutions":["Fix the sortFn id typo or use a registered built-in id ('text', 'alphanumeric', 'datetime', 'basic').","Add the missing function to the table's `sortFns` registry (e.g. extend the sorting row-model feature's sortFns with { mySort: fn }).","Pass a function directly as `columnDef.sortFn` to skip the registry lookup entirely.","Log `table._rowModelFns.sortFns` (Object.keys) to confirm which ids exist before referencing one."],"exampleFix":"// before\n{ accessorKey: 'name', sortFn: 'alphnumeric' } // typo, falls back to basic\n\n// after\n{ accessorKey: 'name', sortFn: 'alphanumeric' }\n// or register the custom one:\n// sortFns: { ...builtInSortFns, localeText: makeLocaleTextSort('de-DE') }\n// { accessorKey: 'name', sortFn: 'localeText' }","handlingStrategy":"validation","validationCode":"const SORT_FN_IDS = new Set(['basic', 'text', 'alphanumeric', 'datetime'])\nfunction assertSortFnRegistered(table, columns) {\n  const registered = new Set(Object.keys(table._rowModelFns.sortFns ?? {}))\n  for (const col of columns) {\n    const sf = col.sortFn\n    if (typeof sf === 'string' && sf !== 'auto' &&\n        !SORT_FN_IDS.has(sf) && !registered.has(sf)) {\n      throw new Error(`sortFn '${sf}' on column '${col.id ?? col.accessorKey}' is not registered`)\n    }\n  }\n}","typeGuard":"function isRegisteredSortFn(table, id) {\n  if (id === undefined || id === 'auto' || typeof id === 'function') return true\n  const sortFns = table._rowModelFns?.sortFns\n  return typeof id === 'string' && !!sortFns && typeof sortFns[id] === 'function'\n}","tryCatchPattern":null,"preventionTips":["Centralize sortFn ids as constants so typos are caught at compile time.","Validate all columnDefs against the registry once at table setup.","Prefer passing a function as sortFn for custom comparators — no registry lookup, no fallback.","Re-audit string sortFn ids whenever upgrading the library or changing row-model packages."],"tags":["sorting","missing-registration","typo","fallback","dev-warning"],"backgroundTag":"unregistered-sort-function","analyzedSha":"d01c01bedbab0ff6c2641f18b2fc9a11545d9bf6","analyzedAt":"2026-08-28T21:52:44.679Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}