Index: pan/gui/pan-tree.cc
===================================================================
--- pan/gui/pan-tree.cc	(revision 211)
+++ pan/gui/pan-tree.cc	(working copy)
@@ -852,7 +852,7 @@
   {
     GtkTreeIter a_it (store->get_iter (a));
     GtkTreeIter b_it (store->get_iter (b));
-    int val = (sort_func)(model, &a_it, &b_it, user_data);
+    int val = sort_func ? (sort_func)(model, &a_it, &b_it, user_data) : (a<b);
     if (reverse) val = -val;
     return val < 0;
   }
Index: pan/gui/header-pane.cc
===================================================================
--- pan/gui/header-pane.cc	(revision 211)
+++ pan/gui/header-pane.cc	(working copy)
@@ -490,9 +490,14 @@
 
   _mid_to_row.clear ();
   _tree_store = build_model (_group, _atree, NULL);
+
+  const bool sort_ascending = _prefs.get_flag ("header-pane-sort-ascending", false);
+  int sort_column = _prefs.get_int ("header-pane-sort-column", COL_DATE);
+  if (sort_column<0 || sort_column>=N_COLUMNS) // safeguard against odd settings
+    sort_column = COL_DATE;
   gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE(_tree_store),
-                                        _prefs.get_int ("header-pane-sort-column", COL_DATE),
-                                        (_prefs.get_flag ("header-pane-sort-ascending", false) ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING));
+                                        sort_column,
+                                        sort_ascending ? GTK_SORT_ASCENDING : GTK_SORT_DESCENDING);
 
   GtkTreeModel * model (GTK_TREE_MODEL (_tree_store));
   GtkTreeView * view (GTK_TREE_VIEW (_tree_view));
