I have an array of items that i want to sort by how many likes each item has with the highest first.
I tried to order the likes for each item, but in the way that i went about it, there was no more association to the original item.
Here is what i did:
$max = $feed->get_item_quantity(); //max number of items in the array
$orderedLike;
for($i = 0; $i < $max; $i++ )
{
$item[$i] = $feed->get_item($i); //gets single items
$orderedLike[$i] = $item[$i]->get_like_count(); //gets number of likes for each item
}
arsort($orderedLike); //sorts the number of likes
echo '<pre>';
foreach ( $orderedLike as $like )
{
echo $like . ' '; //displays the likes
}
echo '</pre>';
This works but then i realized that i cant sort the original array of items anymore because there are two arrays. One with numbers of likes and one with items and values(including the number of likes).
The array im ultimately trying to get into order via the like value is $item
Im not quite sure how to do this.