I have a dataset that features duplicate values of the the primary variable, something like the following: I have achived this by using the following code However, my desired output needs to be ordered such that counts is descending yet col1 remains partitioned, so that I can see, for example, which value from col1 has the highest number of counts.