zoukankan      html  css  js  c++  java
  • 多列表统计之后的数组排序

    public function sortArray($ArrayData,$KeyName1,$SortOrder1 = "SORT_ASC",$SortType1 = "SORT_REGULAR"){
        if(!is_array($ArrayData)) {
            return $ArrayData;
        }
        // Get args number.
        $ArgCount = func_num_args();
        // Get keys to sort by and put them to SortRule array.
        for($I = 1;$I < $ArgCount;$I ++) {
            $Arg = func_get_arg($I);
            if(!preg_match("/SORT/",$Arg)) {
                $KeyNameList[] = $Arg;
                $SortRule[]    = '$'.$Arg;
            }
            else {
                $SortRule[]    = $Arg;
            }
        }
        // Get the values according to the keys and put them to array.
        foreach($ArrayData AS $Key => $Info) {
            foreach($KeyNameList AS $KeyName) {
                ${$KeyName}[$Key] = $Info[$KeyName];
            }
        }
        // Create the eval string and eval it.
        $EvalString = 'array_multisort('.join(",",$SortRule).',$ArrayData);';
        eval ($EvalString);
        return $ArrayData;
    }
    
    $this->sortArray($list,$key,"SORT_DESC");
    
  • 相关阅读:
    [那些你所不知道的鬼畜写法]数据结构小探
    索引
    数据类型
    存储引擎
    事务
    视图、触发器、存储过程、自定义函数
    约束
    数据库介绍
    线程基础、线程池
    操作系统基础
  • 原文地址:https://www.cnblogs.com/pcx105/p/7305274.html
Copyright © 2011-2022 走看看