Skip to content

Instantly share code, notes, and snippets.

@t-cyrill
Created March 1, 2016 05:43
Show Gist options
  • Save t-cyrill/1d321ab07441f178b9b3 to your computer and use it in GitHub Desktop.
Save t-cyrill/1d321ab07441f178b9b3 to your computer and use it in GitHub Desktop.
php sort non ufo
<?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