DEV Community

Discussion on: HackerRank Big Sorting challenge

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);
}

});