Download frontend/src/shared/lib/table-sort.ts from li2895/li: direct link, hf CLI and curl.
- Browser
- Download file 435 Bytes
-
https://huggingface.co/spaces/li2895/li/resolve/main/frontend/src/shared/lib/table-sort.ts
- Command line
-
hf download hf://spaces/li2895/li/frontend/src/shared/lib/table-sort.ts
-
curl -L -o table-sort.ts https://huggingface.co/spaces/li2895/li/resolve/main/frontend/src/shared/lib/table-sort.ts
435 Bytes
| export type SortOrder = "asc" | "desc"; | |
| export type TableSort<Field extends string = string> = { | |
| field: Field; | |
| order: SortOrder; | |
| }; | |
| export function nextTableSort<Field extends string>(current: TableSort<Field>, field: Field, initialOrder: SortOrder = "asc"): TableSort<Field> { | |
| if (current.field !== field) { | |
| return { field, order: initialOrder }; | |
| } | |
| return { field, order: current.order === "asc" ? "desc" : "asc" }; | |
| } | |