sortingFn: (rowA: Row<File>, rowB: Row<File>, columnId: string) => {
const typeA = rowA.getValue("type");
const typeB = rowB.getValue("type");
const nameA = rowA.getValue("name");
const nameB = rowB.getValue("name");
// Check if both are folders or not
const bothFolders = typeA === "folder" && typeB === "folder";
const bothFiles = typeA !== "folder" && typeB !== "folder";
// If both are either folders or files, sort alphabetically
if (bothFolders || bothFiles) {
if (nameA! < nameB!) return -1;
if (nameA! > nameB!) return 1;
return 0;
}
// Sort folders first
// HERE I need to somehow get sorting direction, and swap these values perhaps?
if (typeA === "folder") return 1;
if (typeB === "folder") return -1;
// Default case - sort alphabetically for files
if (nameA! < nameB!) return -1;
if (nameA! > nameB!) return 1;
return 0;
}
sortingFn: (rowA: Row<File>, rowB: Row<File>, columnId: string) => {
const typeA = rowA.getValue("type");
const typeB = rowB.getValue("type");
const nameA = rowA.getValue("name");
const nameB = rowB.getValue("name");
// Check if both are folders or not
const bothFolders = typeA === "folder" && typeB === "folder";
const bothFiles = typeA !== "folder" && typeB !== "folder";
// If both are either folders or files, sort alphabetically
if (bothFolders || bothFiles) {
if (nameA! < nameB!) return -1;
if (nameA! > nameB!) return 1;
return 0;
}
// Sort folders first
// HERE I need to somehow get sorting direction, and swap these values perhaps?
if (typeA === "folder") return 1;
if (typeB === "folder") return -1;
// Default case - sort alphabetically for files
if (nameA! < nameB!) return -1;
if (nameA! > nameB!) return 1;
return 0;
}