I am facing an issue with comparing an array of strings, specifically [ 'a', 'aa', 'aaa' ]. When I use the sort() method, the order changes to ['aaa', 'aa', 'a']. However, I would like to compare these strings based on the characters at index 0 only so that the original input remains unchanged after sorting. I understand why the current order is ['aaa', 'aa', 'a'], but I need a way to sort them based solely on the characters at index 0.
If anyone has a solution, please share. Thank you.