antikirra / array-sort
1.0.0
2023-05-24 13:24 UTC
Requires
- php: ^5.6 || ^7.0 || ^8.0
README
安装
composer require antikirra/array-sort
基本用法
<?php require __DIR__ . '/vendor/autoload.php'; // only if the function has not been defined in the global scope array_sort($array, SORT_DESC, $byKey = true); // if the function could not be defined globally \Antikirra\array_sort($array, SORT_DESC, $byKey = true); // under the hood \Antikirra\ArraySort\ArraySort::sort($array, SORT_DESC, $byKey = true);
演示
<?php require __DIR__ . '/vendor/autoload.php'; $array = ['b' => 3, 'a' => 8, 'c' => 5]; array_sort($array, SORT_DESC, $byKey = true); // Array // ( // [c] => 5 // [b] => 3 // [a] => 8 // ) array_sort($array, SORT_ASC, $byKey = false, $preserveKeys = true); // Array // ( // [b] => 3 // [c] => 5 // [a] => 8 // )