Index: trunk/grails-app/controllers/TaskDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 581)
+++ trunk/grails-app/controllers/TaskDetailedController.groovy	(revision 582)
@@ -78,6 +78,15 @@
         // Remember sort if supplied, otherwise try to restore.
         if(params.sort && params.order) {
-             session.taskSearchSort = params.sort
-             session.taskSearchOrder = params.order
+            // Reset to defaultSort if requested.
+            if(params.sort == 'defaultSort') {
+                params.sort = null
+                params.order = null
+                session.removeAttribute("taskSearchSort")
+                session.removeAttribute("taskSearchOrder")
+            }
+            else {
+                session.taskSearchSort = params.sort
+                session.taskSearchOrder = params.order
+            }
         }
         else if(session.taskSearchSort && session.taskSearchOrder) {
@@ -88,4 +97,6 @@
         if(isFilterApplied) {
             // filterPane:
+            params.sort = params.sort ?: "id"
+            params.order = params.order ?: "desc"
             if(params.sort == "attentionFlag") // See ticket #64 in Trac.
                 params.sort = "id"
@@ -146,5 +157,5 @@
         filterParams.max = params.max
         filterParams.offset = params.offset?.toInteger() ?: 0
-        filterParams.sort = params.sort ?: "attentionFlag"
+        filterParams.sort = params.sort ?: "id"
         filterParams.order = params.order ?: "desc"
 
Index: trunk/grails-app/services/TaskSearchService.groovy
===================================================================
--- trunk/grails-app/services/TaskSearchService.groovy	(revision 581)
+++ trunk/grails-app/services/TaskSearchService.groovy	(revision 582)
@@ -161,7 +161,14 @@
         paginateParams.offset = params?.offset?.toInteger() ?: 0
 
-        def sort = "task." + (params?.sort ?: "attentionFlag")
-        def order = params?.order == "asc" ? "asc" : "desc"
-        def orderBy = " order by " + sort + ' ' + order
+        def orderBy = ''
+        if(params.sort?.contains('.')) // protect against filterpane bug.
+            params.sort = null
+        if(params.sort && params.order) {
+            def sort = "task." + params.sort
+            def order = (params.order == "asc") ? "asc" : "desc"
+            orderBy = " order by " + sort + ' ' + order
+        }
+        else
+            orderBy = " order by task.taskStatus, task.taskPriority, task.targetStartDate"
 
         def namedParams = [:]
@@ -198,7 +205,14 @@
         paginateParams.offset = params?.offset?.toInteger() ?: 0
 
-        def sort = "task." + (params?.sort ?: "attentionFlag")
-        def order = params?.order == "asc" ? "asc" : "desc"
-        def orderBy = " order by " + sort + ' ' + order
+        def orderBy = ''
+        if(params.sort?.contains('.')) // protect against filterpane bug.
+            params.sort = null
+        if(params.sort && params.order) {
+            def sort = "task." + params.sort
+            def order = (params.order == "asc") ? "asc" : "desc"
+            orderBy = " order by " + sort + ' ' + order
+        }
+        else
+            orderBy = " order by task.taskStatus, task.taskPriority, task.targetStartDate"
 
         def namedParams = [:]
Index: trunk/grails-app/taglib/CustomTagLib.groovy
===================================================================
--- trunk/grails-app/taglib/CustomTagLib.groovy	(revision 581)
+++ trunk/grails-app/taglib/CustomTagLib.groovy	(revision 582)
@@ -173,7 +173,14 @@
 
         // Image.
-        def imgSrc = attrs.remove("imgSrc")
-        def imgAlt = attrs.remove("imgAlt")
-        def img = "<img src=${imgSrc} alt=${imgAlt} />"
+        def img = "<img "
+        def imgAttrs = [:]
+        imgAttrs.src = attrs.remove("imgSrc")
+        imgAttrs.alt = attrs.remove("imgAlt")
+        imgAttrs.title = attrs.remove("imgTitle")
+        imgAttrs.each { k, v ->
+            if(v)
+                img += "${k}=\"${v.encodeAsHTML()}\" "
+        }
+        img += "/>"
 
         writer << "<th "
@@ -184,7 +191,7 @@
         }
         writer << ">${link(action:action, params:linkParams) { img } }"
-//         writer << body()
         writer << "</th>"
-    }
+
+    } // sortableColumnWithImg
 
 } // end class
Index: trunk/grails-app/views/taskDetailed/search.gsp
===================================================================
--- trunk/grails-app/views/taskDetailed/search.gsp	(revision 581)
+++ trunk/grails-app/views/taskDetailed/search.gsp	(revision 582)
@@ -89,5 +89,6 @@
                                 <custom:sortableColumnWithImg property="attentionFlag"
                                                                                                 imgSrc="${resource(dir:'images/skin',file:'flag_red.png')}"
-                                                                                                imgAlt="Flag" params="${filterParams}" />
+                                                                                                imgAlt="Flag"
+                                                                                                params="${filterParams}" />
 
                                 <g:sortableColumn property="id" title="Id" params="${filterParams}" />
@@ -103,5 +104,9 @@
                                 <g:sortableColumn  property="taskStatus" title="Status" params="${filterParams}" />
 
-                                <th></th>
+                                <custom:sortableColumnWithImg property="defaultSort"
+                                                                                                imgSrc="${resource(dir:'images/skin',file:'table_sort.png')}"
+                                                                                                imgAlt="Sort"
+                                                                                                imgTitle="Default Sort"
+                                                                                                params="${filterParams}" />
 
                             </tr>
