diff --git a/apps/sensenet/src/components/content-list/content-list.tsx b/apps/sensenet/src/components/content-list/content-list.tsx index a486378f1..1c15ba646 100644 --- a/apps/sensenet/src/components/content-list/content-list.tsx +++ b/apps/sensenet/src/components/content-list/content-list.tsx @@ -674,6 +674,7 @@ export const ContentList = (props: Co } const displayNameInArray = ['DisplayName'] + const sortableColumns = ['DisplayName', 'Path', 'Type', 'Name', 'Version', 'CreationDate', 'ModificationDate'] return (
@@ -720,11 +721,24 @@ export const ContentList = (props: Co getSelectionControl={getSelectionControl} /* If the Order by Column Is The Display. The client will sort it. Due to some locale and indexing issues */ items={ - currentOrder === 'DisplayName' + sortableColumns.includes(String(currentOrder)) ? children?.sort((a, b) => { // If no display Name - const nameA = a?.DisplayName ?? '' // Provide a default value if displayName is undefined - const nameB = b?.DisplayName ?? '' // Provide a default value if displayName is undefined + const nameA = String(a[currentOrder]) ?? '' // Provide a default value if displayName is undefined + const nameB = String(b[currentOrder]) ?? '' // Provide a default value if displayName is undefined + + if (currentDirection === 'asc') { + return nameA.localeCompare(nameB) + } + return nameB.localeCompare(nameA) + }) + : currentOrder === 'CreatedBy' || currentOrder === 'ModifiedBy' + ? children?.sort((a, b) => { + const aTmp = a[currentOrder] as GenericContent + const bTmp = b[currentOrder] as GenericContent + + const nameA = String(aTmp?.DisplayName) ?? '' + const nameB = String(bTmp?.DisplayName) ?? '' if (currentDirection === 'asc') { return nameA.localeCompare(nameB)