Created
May 27, 2015 04:03
-
-
Save Khanashima/3b2939e839a4bdbcc621 to your computer and use it in GitHub Desktop.
1時間以内に解けなければプログラマ失格となってしまう5つの問題の問題4 ref: http://qiita.com/kiimiiis/items/269e88f30ac21a21f763
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//$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