Skip to content

Instantly share code, notes, and snippets.

@Khanashima
Created May 27, 2015 04:03
Show Gist options
  • Save Khanashima/3b2939e839a4bdbcc621 to your computer and use it in GitHub Desktop.
Save Khanashima/3b2939e839a4bdbcc621 to your computer and use it in GitHub Desktop.
1時間以内に解けなければプログラマ失格となってしまう5つの問題の問題4 ref: http://qiita.com/kiimiiis/items/269e88f30ac21a21f763
//$list = array(5, 50, 56);
$list = array(50, 2, 1, 9);
usort($list, 'comp');
echo '<pre>';
print_r(implode('', $list));
echo '</pre>';
function comp($int1, $int2) {
$str1 = (string)$int1;
$str2 = (string)$int2;
if ($str1 === $str2) {
return 0;
}
return -1 * strcmp($str1 . $str2, $str2 . $str1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment