zoukankan      html  css  js  c++  java
  • 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%
    )

    )

  • 相关阅读:
    sql server 跨库操作
    FPGA使用技巧
    MATLAB学习(3)
    FPGA统计摄像头输出-基于MD9T112
    zedboard VmodCAM 图像采集 HDMI输出显示
    VmodCAM图像采集 VGA显示
    EDK中如何使用ISE中生成的IP
    如何将HDL文件实例化到XPS中
    ubuntu下安装 Source insight
    VmodCAM 初始化
  • 原文地址:https://www.cnblogs.com/songyanan/p/9799219.html
Copyright © 2011-2022 走看看