diff --git a/ippisite/ippidb/templates/compound_t_colhead.html b/ippisite/ippidb/templates/compound_t_colhead.html
new file mode 100644
index 0000000000000000000000000000000000000000..386cee7b7ac5ceee8cbf7377619cedb5d6a289b6
--- /dev/null
+++ b/ippisite/ippidb/templates/compound_t_colhead.html
@@ -0,0 +1,17 @@
+{% if col_id in fields %}
+{% with '-'|add:col_id as col_id_desc %}
+  <th scope="col">
+    {% if col_id == sort_by %}
+      <i class="fa fa-arrow-up" title="sorted by ascending {{ col_name }}"></i>
+      <a onclick="modifyUrl('sort_by','{{ col_id_desc }}')" title="click to sort descending on {{ col_name }}" href="#">{{ col_name | capfirst }}</a>
+    {% elif col_id_desc == sort_by %}
+      <i class="fa fa-arrow-down" title="sorted by descending {{ col_name }}"></i>
+      <a onclick="modifyUrl('sort_by','{{ col_id }}')" title="click to sort ascending on {{ col_name }}" href="#">{{ col_name | capfirst }}</a>
+    {% elif col_id in sort_by_options %}
+      <a onclick="modifyUrl('sort_by','{{ col_id }}')" title="click to sort ascending on {{ col_name }}" href="#">{{ col_name | capfirst }}</a>
+    {% else %}
+      {{ col_name | capfirst }}
+    {% endif %}
+  </th>
+{% endwith %}
+{% endif %}
diff --git a/ippisite/ippidb/templates/compound_t_list.html b/ippisite/ippidb/templates/compound_t_list.html
index 5b91101e2c0895ceaa2a540f8a61a38e6b01c987..14953516e227ff87ad95878dfc9e51510b455207 100644
--- a/ippisite/ippidb/templates/compound_t_list.html
+++ b/ippisite/ippidb/templates/compound_t_list.html
@@ -1,49 +1,19 @@
 <table class="table">
   <thead>
     <tr>
-      <th scope="col">#</th>
-      {% if "common_name" in fields %}
-      <th scope="col">Common name</th>
-      {% endif %}
-      {% if "molecular_weight" in fields %}
-      <th scope="col">Molecular weight</th>
-      {% endif %}
-      {% if "a_log_p" in fields %}
-      <th scope="col">AlogP</th>
-      {% endif %}
-      {% if "compound_action_pdb_ids" in fields %}
-      <th scope="col">PDB ligand</th>
-      {% endif %}
-      {% if "mddr_phase" in fields %}
-      <th scope="col">MDDR phase</th>
-      {% endif %}
-      {% if "available_tests" in fields %}
-      <th scope="col">Available tests</th>
-      {% endif %}
-      {% if "biblio_refs" in fields %}
-      <th scope="col">Available publications
-      </th>
-      {% endif %}
-      {% if "nb_acceptor_h" in fields %}
-      <th scope="col">Number of hydrogen bond acceptors
-      </th>
-      {% endif %}
-      {% if "nb_donor_h" in fields %}
-      <th scope="col">Number of hydrogen bond donors
-      </th>
-      {% endif %}
-      {% if "tpsa" in fields %}
-      <th scope="col">Topological Polar Surface Area (TPSA)
-      </th>
-      {% endif %}
-      {% if "nb_rotatable_bonds" in fields %}
-      <th scope="col">Number of rotatable bonds
-      </th>
-      {% endif %}
-      {% if "nb_aromatic_sssr" in fields %}
-      <th scope="col">Number of aromatic Smallest Set of System Rings (SSSR)
-      </th>
-      {% endif %}
+      {% include "compound_t_colhead.html" with col_id="id" col_name="#" %}
+      {% include "compound_t_colhead.html" with col_id="common_name" col_name="common name" %}
+      {% include "compound_t_colhead.html" with col_id="molecular_weight" col_name="molecular weight" %}
+      {% include "compound_t_colhead.html" with col_id="a_log_p" col_name="AlogP" %}
+      {% include "compound_t_colhead.html" with col_id="compound_action_pdb_ids" col_name="PDB ligand(s)" %}
+      {% include "compound_t_colhead.html" with col_id="mddr_phase" col_name="MDDR phase" %}
+      {% include "compound_t_colhead.html" with col_id="available_tests" col_name="available tests" %}
+      {% include "compound_t_colhead.html" with col_id="biblio_refs" col_name="available publications" %}
+      {% include "compound_t_colhead.html" with col_id="nb_acceptor_h" col_name="number of hydrogen bond acceptors" %}
+      {% include "compound_t_colhead.html" with col_id="nb_donor_h" col_name="number of hydrogen bond donors" %}
+      {% include "compound_t_colhead.html" with col_id="tpsa" col_name="TPSA" %}
+      {% include "compound_t_colhead.html" with col_id="nb_rotatable_bonds" col_name="number of rotatable bonds" %}
+      {% include "compound_t_colhead.html" with col_id="nb_aromatic_sssr" col_name="number of aromatic SSSR" %}
       <button type="button" class="btn btn-primary float-right" style="width: inherit!important" data-toggle="modal" data-target="#selectColumns">
         <i class="fa fa-columns" title="customize columns"></i>
       </button>
diff --git a/ippisite/ippidb/views.py b/ippisite/ippidb/views.py
index cad1fc9e5c3e4258b57d7a8612786f247bcc18e0..5d5a6d49b817076ffab464f88537a4f15047890a 100644
--- a/ippisite/ippidb/views.py
+++ b/ippisite/ippidb/views.py
@@ -224,6 +224,8 @@ def compound_list(request):
         sort_by_options[sort_by_option_id] = {'name': compound_fields[sort_by_option_id], 'order':'ascending', 'id': sort_by_option_id}
         sort_by_options['-'+sort_by_option_id] = {'name': compound_fields[sort_by_option_id], 'order':'descending', 'id': sort_by_option_id}
     fields = request.GET.getlist('fields',['id', 'common_name', 'molecular_weight', 'a_log_p', 'compound_action_pdb_ids', 'biblio_refs'])    
+    if 'id' not in fields:
+        fields.append('id')
     return render(request, 'compound_list.html', {'compounds': compounds,
                                                   'count': count,
                                                   'selected_ppis': selected_ppis,