diff --git a/catalog-rest-service/src/main/resources/ui/src/components/my-data-details/FrequentlyJoinedTables.tsx b/catalog-rest-service/src/main/resources/ui/src/components/my-data-details/FrequentlyJoinedTables.tsx index ff025ca9443..aea8b1e4802 100644 --- a/catalog-rest-service/src/main/resources/ui/src/components/my-data-details/FrequentlyJoinedTables.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/components/my-data-details/FrequentlyJoinedTables.tsx @@ -28,19 +28,21 @@ type Props = { const viewCap = 3; const getUniqueTablesWithCount = (tableFQNs: Props['tableList']) => { - return tableFQNs.reduce((resList, curr) => { - let duplicates = false; - for (const table of resList) { - if (table.fqn === curr.fqn) { - table.joinCount += curr.joinCount; - duplicates = true; + return tableFQNs + .reduce((resList, curr) => { + let duplicates = false; + for (const table of resList) { + if (table.fqn === curr.fqn) { + table.joinCount += curr.joinCount; + duplicates = true; - break; + break; + } } - } - return duplicates ? resList : [...resList, curr]; - }, [] as Props['tableList']); + return duplicates ? resList : [...resList, curr]; + }, [] as Props['tableList']) + .sort((a, b) => (a.joinCount < b.joinCount ? 1 : -1)); }; const FrequentlyJoinedTables: FunctionComponent = ({