Using the clever technique found in another answer:
const words = {"be": 3,"a": 5,"an": 3}const sortedEntries = (o) => Object.entries(words) .sort(([k1, v1], [k2, v2]) => v2 - v1 || k1.localeCompare(k2))console.log(sortedEntries(words))