Tog givetvis bort det från ovanstående kodsnuttar... sorry.
// Sort Data by Company, Last Name and First Name
$attribs = array('givenname', 'sn');
if ($_GET['sort'] == "efternamn"){
$attribs = array('sn', 'givenname');
}
else if ($_GET['sort'] == "telefon"){
$attribs = array('telephonenumber','sn', 'givenname');
}
else if ($_GET['sort'] == "mobile"){
$attribs = array('mobile','sn', 'givenname');
}
else if ($_GET['sort'] == "anknytning"){
$attribs = array('pager','sn');
}
else if ($_GET['sort'] == "e-post"){
$attribs = array('mail','sn', 'givenname');
}
for ($i=0; $i<$info["count"]; $i++)
{
$index = $info[$i];
$j=$i;
do {
//create comparison variables from attributes:
$a = $b = null;
foreach($attribs as $attrib){
$a .= $info[$j-1][$attrib][0];
$b .= $index[$attrib][0];
}
// do the comparison
if ($a > $b){
$is_greater = true;
$info[$j] = $info[$j-1];
$j = $j-1;
}else{
$is_greater = false;
}
} while ($j>0 && $is_greater);
$info[$j] = $index;
}