> For the complete documentation index, see [llms.txt](https://tobyisme.gitbook.io/php/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tobyisme.gitbook.io/php/jiang-chuan-ru-de-zhen-lie-zhong-xin-gen-ju-mou-ge-lan-wei-zuo-pai-xu.md).

# 將傳入的陣列重新根據某個欄位做排序

```php
    /**
     * 根據傳入的$arrays裡面的某個欄位$sort_key做排列
     * @param  [array]  $arrays     [需要排序的陣列]
     * @param  [string] $sort_key   [排序依據]
     * @param  [string] $sort_order [ASC or DESC]
     * @param  [string] $sort_type  [字串或是數字]
     */
    function my_sort($arrays,$sort_key,$sort_order=SORT_ASC,$sort_type=SORT_NUMERIC ){
        if(is_array($arrays)){
            foreach ($arrays as $array){
                if(is_array($array )){
                    $key_arrays[] = $array[$sort_key];
                }else{
                    return false;
                }
            }
        }else{
            return false;
        }
        array_multisort($key_arrays,$sort_order,$sort_type,$arrays);
        return $arrays;
    }
```
