[SOLVED]Sort array by popularity
Posted 13 June 2006 - 02:36 PM
Say I have an array with the values ball,doll,cat,cat,dog,cat,ball,cat.
Is there a way to sort the array in order of the most common value inside the array.
I know that array_count_values can count the number of a certain value in an array.
So mayby I could run a loop to go through the array and count how many of each value are the array then put it into something with the value and the number of recurrences of the value then sort them that way?
Is there a much quicker way? Any help appreciated
Posted 13 June 2006 - 02:45 PM
Posted 14 June 2006 - 06:13 PM
But when sorted using 'rsort' it is sorted by the first number rather than both number like '15'. The previous would sort like this:-
How can you sort an array numerically by both digits?
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users