Imagine I am working with an array like this: ['a', 'c', 'bb', 'aaa', 'bbb', 'aa']. My goal is to sort it in the following order:
aaa, aa, a, bbb, bb, c.
this.array= this.array.sort((n1, n2) => n1.localeCompare(n2));
this.array= this.array.sort((n1, n2) => n2.length - n1.length);
However, this approach is not yielding the desired result. How can I correct it?