
February 16th, 2013, 10:21 AM
|
|
Coopercentral
|
|
Join Date: Aug 2002
Location: Rochester, NY
Posts: 24
Time spent in forums: 1 h 38 m 35 sec
Reputation Power: 0
|
|
|
Sorting an array by key/value
Hi:
For my poll I put the results into an array, such as this:
[Choice1] => "0",
[Choice2] => "1",
[Choice3] => "0",
[Choice4] => "0"
The key is the choice and the value is the number of votes. Basically, when the results show, I want to order by the number of votes (most at the top) but then also keep the same sort. For example, if there were NO VOTES, it would show in this order:
Choice1
Choice2
Choice3
Choice4
But, with "Choice2" having 1 vote, it would show:
Choice2
Choice1
Chioce3
Choice4
I asked this years ago, but absolutely was not able to find it. Possibly it was through a private message. I could have sworn someone created a custom "usort" function. Would someone be able to help me out with this?
|