diff --git a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx index 130419aa8e..b4de41fe78 100644 --- a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx +++ b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx @@ -17,16 +17,16 @@ export const ObjectMetadataNavItems = () => { .filter((item) => ['person', 'company', 'opportunity'].includes(item.nameSingular), ) - .sort((objectMetadataItemA, _) => { - if (objectMetadataItemA.nameSingular === 'person') { - return -1; + .sort((objectMetadataItemA, objectMetadataItemB) => { + const order = ['person', 'company', 'opportunity']; + const indexA = order.indexOf(objectMetadataItemA.nameSingular); + const indexB = order.indexOf(objectMetadataItemB.nameSingular); + if (indexA === -1 || indexB === -1) { + return objectMetadataItemA.nameSingular.localeCompare( + objectMetadataItemB.nameSingular, + ); } - - if (objectMetadataItemA.nameSingular === 'opportunity') { - return 1; - } - - return 0; + return indexA - indexB; }), ...activeObjectMetadataItems .filter(