Sorting Elements Of An Array By Frequency In Python