0

i am facing a problem related to array sorting . i want sort this array according to there points . please help me , thanx in advance

Array
(
[5] => Array
    (
        [0] => Array
            (
                [feedbacks] => Array
                    (
                        [emp_name] => test test
                    )

                [0] => Array
                    (
                        [point] => 19
                    )
            )
    )

[9] => Array
    (
        [0] => Array
            (
                [feedbacks] => Array
                    (
                        [emp_name] => a
                    )

                [0] => Array
                    (
                        [point] => 5
                    )
            )
    )

[8] => Array
    (
        [0] => Array
            (
                [feedbacks] => Array
                    (
                        [emp_name] => b
                    )

                [0] => Array
                    (
                        [point] => 23
                    )
            )
    )

[4] => Array
    (
        [0] => Array
            (
                [feedbacks] => Array
                    (
                        [emp_name] => c

                [0] => Array
                    (
                        [point] => -1
                    )
            )
    )

)

andy
  • 5,979
  • 2
  • 27
  • 49
vishnu
  • 11
  • 2
  • Duplicate: please find the solution for this question: http://stackoverflow.com/questions/14873434/sort-php-array-by-multiple-options/14873638#14873638 and http://stackoverflow.com/questions/2699086/sort-multidimensional-array-by-value-2 – Prabu Feb 21 '13 at 10:27

1 Answers1

0

Try this :

<?php

$arr='Your array';


$sort = array();
foreach($arr as $k=>$v) {
    $sort['point'][$k] = $v[0][0]['point']; // $v[0][0] is your point for each array
}

array_multisort($sort['point'], SORT_DESC, $arr);
///array_multisort($sort['point'], SORT_ASC, $arr); // for ascending order

echo "<pre>";
print_r($arr);

?>
Prasanth Bendra
  • 31,145
  • 9
  • 53
  • 73