In PHP, how do I sort traits in vanilla PHP?

PHP, Sorting, Traits, usort, Custom Comparison
This example demonstrates how to sort an array of traits in PHP using the usort function with a custom comparison function.
<?php trait TraitA { public function getValue() { return 5; } } trait TraitB { public function getValue() { return 10; } } $traits = [ new class { use TraitA; }, new class { use TraitB; }, ]; usort($traits, function($a, $b) { return $a->getValue() <=> $b->getValue(); }); foreach ($traits as $trait) { echo $trait->getValue() . "<br>"; } ?>

PHP Sorting Traits usort Custom Comparison