PHP code example of rikudou / array-sort

1. Go to this page and download the library: Download rikudou/array-sort library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rikudou / array-sort example snippets



use rikudou\ArraySort;

$array = [
  1, 2, 3, 4, 5
];

$sorter = new ArraySort($array);

$sortedArray = $sorter->byValue()->maintainKeys()->sortReverse();


use rikudou\ArraySort;

$array = [
  1, 2, 3, 4, 5
];

$sorter = new ArraySort($array);

$sortedArray = $sorter->sortReverse();



use rikudou\ArraySort;
use rikudou\ArraySortPrecedenceConstants;

ArraySort::setOrder([
  ArraySortPrecedenceConstants::BY_KEY
]);




use rikudou\ArraySort;
use rikudou\ArraySortPrecedenceConstants;

ArraySort::setOrder([
  ArraySortPrecedenceConstants::DISCARD_KEY
]);



use rikudou\ArraySort;
use rikudou\ArraySortPrecedenceConstants;

ArraySort::setOrder([
  ArraySortPrecedenceConstants::BY_KEY,
  ArraySortPrecedenceConstants::BY_VALUE,
  ArraySortPrecedenceConstants::DISCARD_KEY,
  ArraySortPrecedenceConstants::MAINTAIN_KEY
]);