I have a poll on my website. For it I put the results into an array such as this:
[Answer1] => "0",
[Answer2] => "1",
[Answer3] => "0",
[Answer4] => "0"
The choice is the key and the number of votes is the value. Essentially when the results show I want to order by the number of votes and then also keep the same sort. So if no votes it would show in the order:
Answer1
Answer2
Answer3
Answer4
But, with "Answer2" having 1 vote it would show:
Answer2
Answer1
Answer3
Answer4
I have tried creating a custom usort function but am having no luck.
Can anybody help me with the logic how to do it please (i can do the PHP myself)?