• PHP 多维数组排序


    $arr1 = array_column($data, 'RateRiseFall');
    $news = array_multisort($arr1, SORT_DESC ,SORT_NUMERIC , $data);
    print_r($data);
    降序

    <pre>Array
    (
    [0] => Array
    (
    [stockCode] => 000001
    [stockName] => 平安银行
    [nowPrice] => 10.37
    [RateRiseFall] => 2.57%
    )

    [1] => Array
    (
    [stockCode] => 000002
    [stockName] => 万科A
    [nowPrice] => 21.01
    [RateRiseFall] => -2.14%
    )

    [2] => Array
    (
    [stockCode] => 002164
    [stockName] => 宁波东力
    [nowPrice] => 2.75
    [RateRiseFall] => -3.17%
    )

    [3] => Array
    (
    [stockCode] => 000006
    [stockName] => 深振业A
    [nowPrice] => 4.67
    [RateRiseFall] => -3.51%
    )

    [4] => Array
    (
    [stockCode] => 600532
    [stockName] => 宏达矿业
    [nowPrice] => 4.38
    [RateRiseFall] => -10.06%
    )

    )

    <pre>

    升序::

    $arr1 = array_column($data, 'RateRiseFall');
    //p($arr1);
    array_multisort($arr1 ,SORT_NUMERIC , $data);

    <pre>Array

    (
    [0] => Array
    (
    [stockCode] => 600532
    [stockName] => 宏达矿业
    [nowPrice] => 4.38
    [RateRiseFall] => -10.06%
    )

    [1] => Array
    (
    [stockCode] => 000006
    [stockName] => 深振业A
    [nowPrice] => 4.67
    [RateRiseFall] => -3.51%
    )

    [2] => Array
    (
    [stockCode] => 002164
    [stockName] => 宁波东力
    [nowPrice] => 2.75
    [RateRiseFall] => -3.17%
    )

    [3] => Array
    (
    [stockCode] => 000002
    [stockName] => 万科A
    [nowPrice] => 21.01
    [RateRiseFall] => -2.14%
    )

    [4] => Array
    (
    [stockCode] => 000001
    [stockName] => 平安银行
    [nowPrice] => 10.37
    [RateRiseFall] => 2.57%
    )

    )

  • 相关阅读:
    Silverlight 5 新特性
    熊市也要活命!高手总结熊市十大生存定律
    WEB服务器硬件配置要求
    你感冒了吗?——风寒来袭全攻略[转]
    看懂此文 你离赚钱就不远了
    开盘尾盘趋势定性法
    感冒全过程
    职业推手自曝微博炒作内幕 十万水军任你调遣!
    股票买卖规则
    通过均线找到牛股
  • 原文地址:https://www.cnblogs.com/songyanan/p/9799219.html
Copyright © 2020-2023  润新知