Computer Science Algorithms in PHP
![](https://camo.githubusercontent.com/edf11b9e810c0f28ae84430f2ecb5f4ddd172104eb219fbd6f62582d68061cfa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f616e696c6f7a6d656e2f636f6d70757465722d736369656e63652d616c676f726974686d732d696e2d7068702e737667)
<?php
use CS\Sort;
use CS\Sort\BubbleSort;
(new Sort)->sort([5, 7, 3, 2, 9, 0, 1, 6, 8, 4], new BubbleSort);
<?php
use \CS\Sort;
use \CS\Sort\InsertionSort;
(new Sort)->sort([5, 7, 3, 2, 9, 0, 1, 6, 8, 4], new InsertionSort);
<?php
use \CS\Sort;
use \CS\Sort\MergeSort;
(new Sort)->sort([5, 7, 3, 2, 9, 0, 1, 6, 8, 4], new MergeSort);
<?php
use \CS\Sort;
use \CS\Sort\QuickSort;
(new Sort)->sort([5, 7, 3, 2, 9, 0, 1, 6, 8, 4], new QuickSort);
<?php
use \CS\Sort;
use \CS\Sort\RadixSort;
(new Sort)->sort([5, 7, 3, 2, 9, 0, 1, 6, 8, 4], new RadixSort);
<?php
use \CS\Search;
use \CS\Search\LinearSearch;
$array = [
['id' => 1, 'name' => 'Joe'],
['id' => 3, 'name' => 'Olivia'],
['id' => 5, 'name' => 'Emma'],
['id' => 6, 'name' => 'Oliver'],
['id' => 10, 'name' => 'Liam'],
['id' => 12, 'name' => 'John'],
['id' => 13, 'name' => 'James'],
['id' => 15, 'name' => 'Sophia'],
['id' => 17, 'name' => 'Benjamin'],
['id' => 18, 'name' => 'Ryan'],
['id' => 19, 'name' => 'Ivy'],
['id' => 21, 'name' => 'Alice'],
['id' => 23, 'name' => 'Max'],
['id' => 24, 'name' => 'Simon'],
];
(new Search)->sort($array, new LinearSearch);
<?php
use \CS\Search;
use \CS\Search\BinarySearch;
$array = [
['id' => 1, 'name' => 'Joe'],
['id' => 3, 'name' => 'Olivia'],
['id' => 5, 'name' => 'Emma'],
['id' => 6, 'name' => 'Oliver'],
['id' => 10, 'name' => 'Liam'],
['id' => 12, 'name' => 'John'],
['id' => 13, 'name' => 'James'],
['id' => 15, 'name' => 'Sophia'],
['id' => 17, 'name' => 'Benjamin'],
['id' => 18, 'name' => 'Ryan'],
['id' => 19, 'name' => 'Ivy'],
['id' => 21, 'name' => 'Alice'],
['id' => 23, 'name' => 'Max'],
['id' => 24, 'name' => 'Simon'],
];
(new Search)->sort($array, new BinarySearch);