Skip to content

Instantly share code, notes, and snippets.

@wuhei
wuhei / quickSortPHPSplFixedArray
Created May 5, 2023 12:58
Quicksort PHP SplFixedArray in PHP5.6, based on a key
/**
* Quicksorting (with partition) implementation to sort SplFixedArray on a specific key,
* I could not find this and I needed this because I'm stuck on PHP5.6 at work -- 2023-05-04 wuhei
*
* @param $arr SplFixedArray, array to sort
* @param $key mixed, array key to sort on
* @param $desc bool if true, sort descending
* @param $leftIndex int, left index of the array to sort, defaults to 0
* @param $rightIndex int, right index of the array to sort, defaults to count($arr) - 1
* @return mixed