public function sort_by( $attribute, $sort_flag = SORT_REGULAR )
	{
		$values = array();

		for ( $i = count( $this ) -1; $i >= 0; --$i ) {
			$values[] = $this[$i]->$attribute;
		}

		$values = array_unique($values);

		sort( $values, $sort_flag );

		$new = new self();

		foreach ( $values as $value ) {
			for ( $i = count( $this ) -1; $i >= 0; --$i ) {
				if ( $value == $this[$i]->$attribute ) {
					$new[] = $this[$i];
				}
			}
		}

		return $new;
	}
public function sort_by( $attribute, $sort_flag = SORT_REGULAR )
	{
		$values = array();

		for ( $i = count( $this ) -1; $i >= 0; --$i ) {
			$values[] = $this[$i]->$attribute;
		}

		$values = array_unique($values);

		sort( $values, $sort_flag );

		$new = new self();

		foreach ( $values as $value ) {
			for ( $i = count( $this ) -1; $i >= 0; --$i ) {
				if ( $value == $this[$i]->$attribute ) {
					$new[] = $this[$i];
				}
			}
		}

		return $new;
	}
public function sort_by ( $ attribute , $ sort_flag = SORT_REGULAR ) { $ values = array ( ) ; for ( $ i = count ( $ this ) - 1 ; $ i >= 0 ; -- $ i ) { $ values [ ] = $ this [ $ i ] -> $ attribute ; } $ values = array_unique ( $ values ) ; sort ( $ values , $ sort_flag ) ; $ new = new self ( ) ; foreach ( $ values as $ value ) { for ( $ i = count ( $ this ) - 1 ; $ i >= 0 ; -- $ i ) { if ( $ value == $ this [ $ i ] -> $ attribute ) { $ new [ ] = $ this [ $ i ] ; } } } return $ new ; }
Sorts results by specific field and direction.

@param string $attribute Attribute to sort by.
@param string $sort_flag Sort direction.

@return this for chaining
Sorts results by specific field and direction .