Array Sorting
Posted: Tue Jul 21, 2009 5:58 am
This might be simpler than I'm making it, but I still need help. I have an array with corresponding names and values.
For example:
$scoresbefore = array("Bob", 9, "Karen", 3, "James", 12, "Pete", 6, "Kelly", 7);
$scoresafter = array("Karen", 3,"Pete", 6,"Kelly", 7,"Bob", 9,"James", 12);
What I'm trying to do is sort by the values and retain the corresponding name in front of it. Maybe there is a better way of doing this. If you know of one please tell me. Any help would be appreciated. Thanks.
For example:
$scoresbefore = array("Bob", 9, "Karen", 3, "James", 12, "Pete", 6, "Kelly", 7);
$scoresafter = array("Karen", 3,"Pete", 6,"Kelly", 7,"Bob", 9,"James", 12);
What I'm trying to do is sort by the values and retain the corresponding name in front of it. Maybe there is a better way of doing this. If you know of one please tell me. Any help would be appreciated. Thanks.