The Ds\Set::sorted() function is an inbuilt function in PHP which is used to return a sorted copy of given set.
Ds\Set public Ds\Set::sorted ([ callable $comparator ])
Parameters: This function accepts a comparator function according to which the values will be compared while sorting the Set. The comparator should return the following values based on the comparison of two values passed to it as a parameter:
- 1: if the first element is expected to be less than the second element.
- -1: if the first element is expected to be greater than the second element.
- 0: if the first element is expected to be equal to the second element.
Return value: It returs the sorted copy of the given set.
Below programs illustrate the Ds\Set::sorted() function in PHP:
Ds\Set Object (  => 10  => 20  => 30 )
Ds\Set Object (  => 7  => 6  => 5  => 4  => 3  => 2  => 1 )
- PHP | Ds\Map sorted() Function
- PHP | Ds\Vector sorted() Function
- PHP | Ds\Sequence sorted() Function
- PHP | Ds\Deque sorted() Function
- What is the Efficient way to insert a number into a sorted array of numbers?
- How to get the function name inside a function in PHP ?
- PHP | min( ) Function
- PHP | ord() Function
- PHP | Ds\Set xor() Function
- PHP | max( ) Function
- p5.js | sq() function
- PHP | each() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.