DEV Community

HackerRank Big Sorting challenge

webit on March 15, 2021

I love to take HackerRank challenges. Those are great to practice programming and improving your overall skills. I do them quite often - just like ...
Collapse
 
robencom profile image
robencom

Your post was helpful, it helped me figure out this solution for PHP:

usort($unsorted, function($a, $b) {
$strlenA = strlen($a);
$strlenB = strlen($b);
if ($strlenA != $strlenB) {
return $strlenA - $strlenB;
} else {
return strcoll($a, $b);
}

});