MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / toggleSort

Function toggleSort

packages/core/src/widgets/table.ts:341–354  ·  view source on GitHub ↗
(
  currentColumn: string | undefined,
  currentDirection: SortDirection | undefined,
  clickedColumn: string,
)

Source from the content-addressed store, hash-verified

339 * @returns New sort state
340 */
341export function toggleSort(
342 currentColumn: string | undefined,
343 currentDirection: SortDirection | undefined,
344 clickedColumn: string,
345): SortResult {
346 if (currentColumn !== clickedColumn) {
347 // New column: start ascending
348 return Object.freeze({ column: clickedColumn, direction: "asc" });
349 }
350
351 // Same column: toggle direction
352 const newDirection = currentDirection === "asc" ? "desc" : "asc";
353 return Object.freeze({ column: clickedColumn, direction: newDirection });
354}
355
356/* ========== Row Key Extraction ========== */
357

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected