Created
March 1, 2016 05:43
-
-
Save t-cyrill/1d321ab07441f178b9b3 to your computer and use it in GitHub Desktop.
php sort non ufo
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
<?php | |
$c = [ | |
'6.9.3-1' => '10', | |
'6.9.3-10' => '10', | |
'6.9.3-2' => '10', | |
]; | |
uksort($c, function ($a, $b) { | |
$a = preg_split('/[^0-9]/', $a); | |
$b = preg_split('/[^0-9]/', $b); | |
if ($a == $b) return 0; | |
return $a > $b ? -1 : 1; | |
}); | |
var_dump($c); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment