#!/usr/bin/env php
<?php
function merge(&$a, &$b) {
    
$c = array();
    while (!empty(
$a) && !empty($b)) {
        if (
$a[0] > $b[0]) {
            
$c[] = $b[0];
            
array_shift($b);
        } else {
            
$c[] = $a[0];
            
array_shift($a);
        }
    }
    while (!empty(
$a)) {
        
$c[] = $a[0];
        
array_shift($a);
    }
    while (!empty(
$b)) {
        
$c[] = $b[0];
        
array_shift($b);
    }
    return 
$c;
}

function 
mergesort(&$a) {
    
$n count($a);
    if (
$n <= 1) {
        return 
$a;
    }

    
$l1 = array();
    
$l2 = array();
    
$i 0;
    while (
$i $n 2) {
        
$l1[] = $a[$i];
        
$i++;
    }
    while (
$i $n) {
        
$l2[] = $a[$i];
        
$i++;
    }

    
$l1 mergesort($l1);
    
$l2 mergesort($l2);
    return 
merge($l1$l2);
}
$numbers = array(4744805411062515651208921855170086026840395770444281018129730790516136141283570682501829657695654555439126177379618216407294496839811062536538960760611387478498183585531536445561548301248646336012894931894713514354359969161366312031888420407192337952273572604410944015182455202391099467121107893495592868510700148765273016388343881444420725947125904969416929209867127153211546173505935080091106700528430204045104592877513304766424998399014511647671175404600644832496365016297104873279450361531721718630111761603381183622513817110491720671278139307209713152363881451774341928484582710005441667871288380233084105307965812493415071276652307172201503912436980251788138681449271074199432757927097281910433791891592595484462468972146477331519941724069973006234640528316142719494479071233172922843782916761253835093523476912160602399959263848123435808014098164318284718541197394207131792754687828791533457635998214984264287823810240649991834342299);

$start microtime(true);
for (
$i 0$i 3000$i++) {
    
mergesort($numbers);
}
echo (
microtime(true)-$start)."\n";
?>