我试图通过多个键对多维数组进行排序,我不知道从哪里开始.我看着uasort,但不太确定如何为我需要的东西编写函数.
我需要按州,然后是event_type,然后按日期排序.
我的数组看起来像这样:
    Array
(
    [0] => Array
        (
            [ID] => 1
            [title] => Boring Meeting
            [date_start] => 2010-07-30
            [time_start] => 06:45:PM
            [time_end] => 
            [state] => new-york
            [event_type] => meeting
        )
    [1] => Array
        (
            [ID] => 2
            [title] => Find My Stapler
            [date_start] => 2010-07-22
            [time_start] => 10:45:AM
            [time_end] => 
            [state] => new-york
            [event_type] => meeting
        )
    [2] => Array
        (
            [ID] => 3
            [title] => Mario Party
            [date_start] => 2010-07-22
            [time_start] => 02:30:PM
            [time_end] => 07:15:PM
            [state] => …我有以下数组:
$arr = [
    [
        'user_id' => 1,
        'product_id' => 1
    ],
    [
        'user_id' => 1,
        'product_id' => 2
    ],
    [
        'user_id' => 1,
        'product_id' => 3
    ],
    [
        'user_id' => 2,
        'product_id' => 1
    ],
    [
        'user_id' => 2,
        'product_id' => 2
    ],
    [
        'user_id' => 3,
        'product_id' => 1
    ]
];
我想对它进行排序,看起来像这样:
$arr = [
    [
        'user_id' => 1,
        'product_id' => 1
    ],
    [
        'user_id' => 2,
        'product_id' => 1
    ],
    [
        'user_id' => 3,
        'product_id' => 1 …我有一个数组,每个数组有4个值
$array[0] = array('amount' => '98.60', 'typeA' => '98.52', 'typeB' => '58.52', 'typeC' => '90.2');
$array[1] = array('amount' => '55.80', 'typeA' => '25.36', 'typeB' => '36.54', 'typeC' => '36.99');
$array[2] = array('amount' => '42.68', 'typeA' => '64.26', 'typeB' => '65.87', 'typeC' => '99.24');
$array[3] = array('amount' => '812.3', 'typeA' => '36.27', 'typeB' => '23.25', 'typeC' => '94.35');
我需要根据每个键的最高值按以下顺序排列数组:
所以最后我将看到哪个是最高金额。
希望这里能有所帮助,谢谢!
我有一个多维数组,看起来像:
$arr=Array
(
    [0] => Array
        (
            [0] => TEAM1
            [1] => 3
            [2] => 0
            [3] => 422.47
            [4] => 192.62
        )
    [1] => Array
        (
            [0] => TEAM2
            [1] => 2
            [2] => 1
            [3] => 402.14
            [4] => 210.70
        )
    [2] => Array
        (
            [0] => TEAM3
            [1] => 3
            [2] => 0
            [3] => 376.79
            [4] => 174.64
        )
)
这5栏与团队名称,#胜利,#损失,#的得分,#的得分有关。
我将如何$arr按第1列(获胜次数)(降序),第2列(损失数)(升序),然后第3列(要获得的点数)(降序)进行排序
usort($childs, function($a, $b) {
    return $a['parent_id'] - $b['parent_id'];
});
在这里,我用1个字段对它进行排序,如何添加更多字段来对它们进行排序?,就好像它是ORDER BY field1, field2, field3在Mysql中一样