I have an array of strings: [ 'a', 'aa', 'aaa' ]. If I compare those using the sort() method, I am getting something like this: ['aaa', 'aa', 'a'] but what I want is to compare them based on the characters and index 0 only so the input above will not change when I apply the sort() method. I know the reason why I am getting this ['aaa', 'aa', 'a'] but I need to compare them only based on the chars at 0s.
Please someone let me know.