I have an array that I need to sort by its elements and then alphabetically. For instance:
55 The
32 ASomething
32 BSomething
ASomething should come before Bsomething because:
1) they have the same number
2) A comes before B alphabetically
So, you sort first by the number of occurrences, then alphabetically
What is the best way to do this. I use merge sort to sort counters, but how can I put an operator to check if it has the same number, it is sorted alphabetically (maybe more than two words).
SOLUTION: what I did was sort the data merge before I did the merge sort by data counts, and that was good enough. Thank you all for your help.
source
share