diff --git a/modules/ldapstatus/templates/ldapstatus.php b/modules/ldapstatus/templates/ldapstatus.php
index 2fb613e055a356964ddcf50de85dbbb830defb61..9bf913c307c84e36b7c6f8938179a1f5a1493a90 100644
--- a/modules/ldapstatus/templates/ldapstatus.php
+++ b/modules/ldapstatus/templates/ldapstatus.php
@@ -31,17 +31,17 @@ $this->includeAtTemplateBase('includes/header.php');
 <table class="attributes" style="font-size: small; width: 100%; border: 1px solid #aaa">
 	<tr>
 		<th>Name of institusion</th>
-		<th>Conf</th>
-		<th>Ping</th>
-		<th colspan="3">Cert</th>
-		<th>Admin</th>
-		<th>S=bogus</th>
-		<th>test</th>
-		<th>S=test</th>
-		<th>T-bind()</th>
-		<th>Org-info</th>
-		<th>Meta</th>
-		<th>Time</th>
+		<th><a href="?sort=conf">Conf</a></th>
+		<th><a href="?sort=ping">Ping</a></th>
+		<th colspan="3"><a href="?sort=cert">Cert</a></th>
+		<th><a href="?sort=adminBind">Admin</a></th>
+		<th><a href="?sort=ldapSearchBogus">S=bogus</a></th>
+		<th><a href="?sort=configTest">test</a></th>
+		<th><a href="?sort=ldapSearchTestUser">S=test</a></th>
+		<th><a href="?sort=ldapBindTestUser">T-bind()</a></th>
+		<th><a href="?sort=getTestOrg">Org-info</a></th>
+		<th><a href="?sort=configMeta">Meta</a></th>
+		<th><a href="?sort=time">Time</a></th>
 	</tr>
 
 <?php
@@ -116,8 +116,14 @@ foreach($this->data['sortedOrgIndex'] as $orgkey) {
 		showRes('configMeta',  $res, $this);
 		
 		
+		if ($res['time'] > 2.0) {
+			echo('<td style="text-align: right; color: #700">' . ceil($res['time']*1000) . '&nbsp;ms</td>');
+		} else if ($res['time'] > 0.3) {
+			echo('<td style="text-align: right">' . ceil($res['time']*1000) . '&nbsp;ms</td>');
+		} else {
+			echo('<td style="text-align: right; color: #060">' . ceil($res['time']*1000) . '&nbsp;ms</td>');
+		}
 		
-		echo('<td style="text-align: right">' . ceil($res['time']*1000) . '&nbsp;ms</td>');
 		echo('</tr>');
 		
 		if ($this->data['showcomments'] && array_key_exists('comment', $this->data['orgconfig'][$orgkey])) {
diff --git a/modules/ldapstatus/www/index.php b/modules/ldapstatus/www/index.php
index d98e1f42d8200e3e0234d82e7ffca53ba673968a..205b64af9b1cf10d43a173f057ae2708e3539a90 100644
--- a/modules/ldapstatus/www/index.php
+++ b/modules/ldapstatus/www/index.php
@@ -170,10 +170,45 @@ $session->setData('module:ldapstatus', 'results', $results);
 
 $lightCounter = array(0,0,0);
 
-function resultCode($res) {
+
+
+function resultCode($res, $sortby = NULL) {
 	global $lightCounter;
 	$code = '';
 	$columns = array('config', 'ping', 'cert', 'adminBind', 'ldapSearchBogus', 'configTest', 'ldapSearchTestUser', 'ldapBindTestUser', 'getTestOrg', 'configMeta');
+	
+	if (!empty($sortby) && in_array($sortby, $columns)) {
+		
+			
+		if (array_key_exists($sortby, $res)) {
+		
+			if ($res[$sortby][0]) {
+				$code .= '0';
+			} else {
+				$code .= '2';
+			}
+			
+		} else {
+			$code .= '1';
+		}
+		
+		if ($sortby == 'cert') {
+			if (array_key_exists($sortby, $res) && isset($res[$sortby]['expire'])) 
+				$code .= sprintf("%05s", (99999 - $res[$sortby]['expire']) );
+			else
+				$code .= '-----';
+		}
+		
+		$code .= '|';
+	}
+	if ($sortby === 'time') {
+		if (array_key_exists($sortby, $res)) 
+			$code .= sprintf("%05s", floor(1000*$res[$sortby]) );
+		else
+			$code .= '-----';
+		$code .= '|';
+	}
+	
 	foreach ($columns AS $c) {
 		if (array_key_exists($c, $res)) {
 			if ($res[$c][0]) {
@@ -195,7 +230,7 @@ function resultCode($res) {
 	
 $ressortable = array();
 foreach ($results AS $key => $res) {
-	$ressortable[$key] = resultCode($res[0]);
+	$ressortable[$key] = resultCode($res[0], (isset($_REQUEST['sort']) ? $_REQUEST['sort'] : NULL));
 }
 arsort($ressortable);
 #echo '<pre>'; print_r($ressortable); exit;