```ts
function sortByLen(words: string[]): string[] {
  return words.slice().sort((a, b) => {
    if (a.length === b.length) {
      return a.localeCompare(b);
    }
    return a.length - b.length;
  });
}
```