Hi Everyone,
Im getting difficulties in sorting this array, by the way I want to sort this array according to its subarray for example
[0] => Array
(
[0] => Array
(
[0] => Are
[1] => Google
[2] => and
[3] => Zynga
[4] => Working
[5] => on
[6] => a
[7] => Gaming
[8] => Deal?
)
[1] => Array
(
[1] => Google
[4] => Working
)
[2] => Array
(
[3] => Zynga
)
[3] => Array
(
[1] => Google
)
[4] => Array
(
[1] => Google
[3] => Zynga
)
[5] => Array
(
[1] => Google
)
after sorting the output should be like this
[1] => Array
(
[0] => Array
(
[0] => Are
[1] => Google
[2] => and
[3] => Zynga
[4] => Working
[5] => on
[6] => a
[7] => Gaming
[8] => Deal?
)
[1] => Array
(
[1] => Google
[4] => Working
)
[4] => Array
(
[1] => Google
[3] => Zynga
)
[3] => Array
(
[1] => Google
)
[2] => Array
(
[3] => Zynga
)
[5] => Array
(
[1] => Google
)
In other words I want to sort this array according to its count value... Any help will be highly appreciated..
I will us this in grouping related topics in RSS feeds any tips that will make my work easily , Im going to get many RSS in different website and I will put it in one page by that I will gather all the related topics from other website... It is similar in techmeme.com ... Pls Help me...
Array Sorting
Moderator: General Moderators
Re: Array Sorting
Hi,
I have this array sorting function, may this will help you
I have this array sorting function, may this will help you
Code: Select all
function sort_array($array, $key, $order)
{
if ($order=="DESC")
$or="arsort";
else
$or="asort";
for ($i = 0; $i < sizeof($array); $i++)
{
$sort_values[$i] = $array[$i][$key];
}
$or($sort_values);
reset ($sort_values);
while (list ($arr_key, $arr_val) = each ($sort_values))
{
$sorted_arr[] = $array[$arr_key];
}
return $sorted_arr;
}