c2ec1c97c9
A poor man's formatter since I didn't like any of the other ones I found. The original C++ source sometimes put newlines and sometimes not.
Codemods:
codemod '([;{}])([^\n])' '\1\n\2'
codemod -m '\s*<\?php\s+' '<?php\n\n'
codemod '\t' ' '
I hand-fixed all the failing tests
28 linhas
417 B
PHP
28 linhas
417 B
PHP
<?php
|
|
|
|
// Comparison function
|
|
function cmp($a, $b) {
|
|
if ($a == $b) {
|
|
return 0;
|
|
}
|
|
return ($a < $b) ? -1 : 1;
|
|
}
|
|
|
|
// Array to be sorted
|
|
$array = array(
|
|
'a' => 4,
|
|
'b' => 8,
|
|
'c' => -1,
|
|
'd' => -9,
|
|
'e' => 2,
|
|
'f' => 5,
|
|
'g' => 3,
|
|
'h' => -4,
|
|
);
|
|
$arrayObject = new ArrayObject($array);
|
|
print_r($arrayObject);
|
|
|
|
// Sort and print the resulting array
|
|
$arrayObject->uasort('cmp');
|
|
print_r($arrayObject);
|