PHP - Função Ds Deque sort ()

A função Ds \ Deque :: sort () pode classificar o deque no local.

Sintaxe

public void Ds\Deque::sort([ callable $comparator ] )

A função Ds \ Deque :: sort () pode classificar o deque no local usando uma função comparadora opcional.

A função Ds \ Deque :: sort () não retorna nenhum valor.

Exemplo 1

<?php 
   $deque = new \Ds\Deque([5, 3, 8, 1, 7, 4]); 
   echo("The elements in deque: \n"); 
   print_r($deque); 
   
   $deque->sort(); 
   echo("The elements after sorting in deque: \n"); 
   print_r($deque);
?>

Exemplo 2

<?php 
   $deque = new \Ds\Deque([5, 3, 8, 1, 7, 4]); 
   echo("The elements of deque: \n"); 
   print_r($deque); 
   
   $deque->sort(function($first, $second) { 
      return $first <= $second; 
   }); 
   echo("The elements after sorting in deque: \n"); 
   print_r($deque);
?>