The Ds\Vector::sort() function is an inbuilt function in PHP which is used to sort the elements of vector in-place. This will arrange the vector elements in increasing order.
void public Ds\Vector::sort( $comparator )
Parameters: This function accepts a single parameter $comparator which is used to hold the sort function.
Return Value: This function does not returns any value.
Below programs illustrate the Ds\Vector::sort() function in PHP:
Original vector Ds\Vector Object (  => 6  => 5  => 4  => 3  => 2  => 1 ) Sorted elements Ds\Vector Object (  => 1  => 2  => 3  => 4  => 5  => 6 )
Original vector Ds\Vector Object (  => 3  => 6  => 1  => 2  => 9  => 7 ) Decreasing Sorted elements Ds\Vector Object (  => 9  => 7  => 6  => 3  => 2  => 1 )
- PHP | Ds\Map sort() Function
- PHP Ds\Set sort() Function
- PHP | sort() Function
- p5.js | sort() function
- Node.js | sort() function
- PHP | Ds\Deque sort() Function
- PHP | Ds\Sequence sort() Function
- p5.js | Quick Sort
- p5.js | Bubble Sort
- Sort an array of dates in PHP
- How to sort a list alphabetically using jQuery ?
- Sort a multidimensional array by date element in PHP
- Sort array of objects by object fields in PHP
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.