src/Datastructure/Stackqueue/Stack.php
public function sort(): void {
        $r = new Stack();
        while (!$r->isEmpty()) {
            $tmp = $this->pop();

            while ((!$r->isEmpty()) && (Comparator::lessThan($r->peek(), $tmp))) {
                $this->push($r->pop());
            }
            $r->push($tmp);
        }
        while (!$r->isEmpty()) {
            $this->push($r->pop());
        }
    }
public function sort(): void {
        $r = new Stack();
        while (!$r->isEmpty()) {
            $tmp = $this->pop();

            while ((!$r->isEmpty()) && (Comparator::lessThan($r->peek(), $tmp))) {
                $this->push($r->pop());
            }
            $r->push($tmp);
        }
        while (!$r->isEmpty()) {
            $this->push($r->pop());
        }
    }
public function sort ( ) : void { $ r = new Stack ( ) ; while ( ! $ r -> isEmpty ( ) ) { $ tmp = $ this -> pop ( ) ; while ( ( ! $ r -> isEmpty ( ) ) && ( Comparator :: lessThan ( $ r -> peek ( ) , $ tmp ) ) ) { $ this -> push ( $ r -> pop ( ) ) ; } $ r -> push ( $ tmp ) ; } while ( ! $ r -> isEmpty ( ) ) { $ this -> push ( $ r -> pop ( ) ) ; } }
sorts the stack in descending order

TODO add ascending order
sorts the stack in descending order