Warning: Invalid argument supplied for foreach() in /home/jihswbiz/public_html/t6.gwilt.org/refDox.php on line 212
Docs-sorter

 

ReLoad

Keys


Functions

arraybrowsercolorcookiedatetimeDBdebugdeviceDSTequiverrorflagsfontformatgeo
holidayhtmlisjsonmathparsePHPprintsearchsortstringtabletexttracetype
VOTDweatherxml

Function  sorter   Lines 1970-2002 (32 lines) file  utils.php   Last mod: Fri 2021-05-14 21:45:07

function sorter ( &$a$k$asc=true$icase=true )
        {
#-k     string sort array
#-      crude sort of an array by key; array structure is array[0:n]['key']
#-      $icase = true to ignore case (default)

        
$cnt count($a)-1;
        
$change true;
        while (
$change  and  ($cnt 0))
                {
                
$change false;
                for (
$i=0;$i<=$cnt-1;$i++)
                        {
                        
$swap false;
                        if ( 
$asc and ( $icase) and (strtolower($a[$i][$k]) > strtolower($a[$i+1][$k])))        { $swap true; } else
                        if ( 
$asc and (!$icase) and ($a[$i][$k] > $a[$i+1][$k]))                                { $swap true; } else
                        if (!
$asc and ( $icase) and (strtolower($a[$i][$k]) < strtolower($a[$i+1][$k])))        { $swap true; } else
                        if (!
$asc and (!$icase) and ($a[$i][$k] < $a[$i+1][$k]))                                { $swap true; }

                        if (
$swap)
                                {       
#swap
                                
$junk $a[$i];
                                
$a[$i] = $a[$i+1];
                                
$a[$i+1] = $junk;
                                
$change true;
                                }
                        }
                
$cnt--;
                }

        return 
$a;
        }

?>