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
                    )
            )
    )

)

4

1 回答 1

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);

?>
于 2013-02-21T10:24:07.157 回答