Hi everyone! I have been trying to decide how to do this for quite some time and I finally decided I just need some assistance. I have an array of Comparable objects and I want to sort them, but I want to do it in a weird way. I’d like to sort from highest to lowest, but also place repeated entries at the front of the array. The more times the appear the more priority they get so something like
unsorted = {7, 2, 3, 2, 1, 5}
will get sorted as
sorted = {2, 2, 7, 5, 3, 1}
Where the 2s get put at the front because they appear twice. Here is another example:
unsorted = {1, 2, 3, 2, 4, 2, 3, 5, 3, 5}
will look like
sorted = {3, 3, 3, 2, 2, 2, 5, 5, 4, 1}
where you can see that there are three 3s and three 2s, so the 3s appear first in the sorted array. 5 appears after this because there are only two of them. Lastly we get 4 and 1.
Does this make sense?