phpstreams\Stream::isSorted PHP Method

isSorted() public method

This is used to optimize some stream operations, such as distinct(), which only needs constant memory when operating on a sorted list. Any stream operations that potentially change the sorting order should override this method to properly reflect the actual sorting order.
public isSorted ( ) : boolean
return boolean
    public function isSorted()
    {
        if ($this->source instanceof Stream) {
            return $this->source->isSorted();
        } else {
            return false;
        }
    }

Usage Example

Example #1
0
 public function testIsSortedWithArray()
 {
     $instance = new Stream([]);
     $this->assertFalse($instance->isSorted());
 }