sort()
Sorts an array in ascending order. In compiled (AOT) code, indexed arrays with runtime-typed (`mixed`) elements are accepted when every element is `null`, `bool`, `int`, `float`, or `string`. A non-scalar element (nested array, object, resource, or boxed callable) terminates execution before sorting with `Fatal error: sorting Mixed arrays containing non-scalar values is not supported`. This deliberate restriction does not implement full PHP container ordering.
sort()
function sort(array $array): bool
Sorts an array in ascending order. In compiled (AOT) code, indexed arrays with runtime-typed (mixed) elements are accepted when every element is null, bool, int, float, or string. A non-scalar element (nested array, object, resource, or boxed callable) terminates execution before sorting with Fatal error: sorting Mixed arrays containing non-scalar values is not supported. This deliberate restriction does not implement full PHP container ordering.
Parameters:
$array(array), passed by reference
Returns: bool
Availability
- Compiled (AOT): supported by the Elephc code generator.
eval()(magician interpreter): supported — declarative interpreter builtin (crates/elephc-magician/src/interpreter/builtins/array/sort.rs).
No examples yet — check examples/ and showcases/ for usage patterns.
Internals
For how sort is implemented in the compiler, see the internals page.