I have the array of strings that I want to sort in a custom order My array looks like this
["E", "D", "CC", "C", "B", "BB", "BBA", "BBD", "BBE", "BBB", "BBBC", "A", "AA"]
In my sorted array I want to show the words alphabetically but the words with large number of continuous letter should appear first.
If more number of words have same length of continuous letter then need to consider next letter alphabetically.
My expected result should look like this
["AA", "A","BBBC", "BBB","BBA", "BBD", "BBE", "BB", "B", "CC", "C", "D", "E"]
I tried to sort using the default sort() function but it didn't give me expected results. So please give your suggestions
.sort()can have a callback function as argument to be used as a comparer of 2 elements. You can write your sorting rule thereBBAgo?BBAAcome beforeBBAB?