commit 92e522dbb7039adeddce7e54f76ca1768a7a68f1
Author: Andreas Kohlbecker <a.kohlbecker@bgbm.org>
Date:   Tue Jan 7 12:40:26 2020 +0100

    ref #8739 description sources in alphabetical order

diff --git a/modules/cdm_dataportal/includes/common.inc b/modules/cdm_dataportal/includes/common.inc
index 35adc038..f3bd2d2f 100755
--- a/modules/cdm_dataportal/includes/common.inc
+++ b/modules/cdm_dataportal/includes/common.inc
@@ -667,7 +667,7 @@ function render_cdm_entity_link($cdm_entity) {
 
   switch ($cdm_entity->class) {
     case 'TaxonDescription':
-      $link =  render_cdm_description($cdm_entity);
+      $link =  '<span class="' . html_class_attribute_ref($cdm_entity) . '">' . $cdm_entity->titleCache . '</span> ' . icon_link(path_to_description($cdm_entity->uuid));
       break;
     default:
       $link = '<span class="error">UNSUPPORTED CDM ENTITY TYPE</span>';
diff --git a/modules/cdm_dataportal/includes/descriptions.inc b/modules/cdm_dataportal/includes/descriptions.inc
index 19adde65..d15b4319 100644
--- a/modules/cdm_dataportal/includes/descriptions.inc
+++ b/modules/cdm_dataportal/includes/descriptions.inc
@@ -2119,36 +2119,6 @@ function make_pseudo_feature($representation_L10n, $pseudo_feature_key = null){
 
 }
 
-
-/**
- * Renders the description and adds a link to the description detail page
- *
- * @param object $description
- *     the cdm description entity which will be linked to
- *
- * @param bool $show_description_elements
- *     if True the description elements will be rendered
- * @param $descriptive_dataset_uuid
- *     the data set which should be passed to the description detail page
- *
- * @return string the markup for the description
- */
-function render_cdm_description($description, $show_description_elements = False, $descriptive_dataset_uuid = NULL) {
-
-  $out = '<span class="' . html_class_attribute_ref($description) . '">' . $description->titleCache . '</span>';
-  $path_to_description = path_to_description($description->uuid, $descriptive_dataset_uuid);
-  if($show_description_elements){
-    $out = render_description_string($description, get_root_nodes_for_dataset($description));
-  }
-  $out .= ' ' . icon_link($path_to_description);
-
-  if($show_description_elements){
-    $out .= '<div class="content-caption">'. t('Bracketed numbers denote sample size') . '</div>';
-  }
-
-  return $out;
-}
-
 /**
  * @param $description
  * @param $root_nodes
@@ -2320,16 +2290,17 @@ function  compose_description_table($description_uuid, $descriptive_dataset_uuid
           case 'TaxonDescription':
           case 'NameDescription':
           case 'SpecimenDescription':
-            $source_link_markup = render_cdm_description($cdm_source_entity);
+            $source_link_markup = render_cdm_entity_link($cdm_source_entity);
             break;
           default:
             $source_link_markup = '<span class="error">unhandled CdmSource</span>';
         }
-        $items[] = [
+        $items[$cdm_source_entity->titleCache] = [
           'data' => $source_link_markup
         ];
       }
     }
+    ksort($items);
     $render_array['sources'] = [
       '#title' => 'Sources',
       '#theme' => 'item_list',
diff --git a/modules/cdm_dataportal/includes/pages.inc b/modules/cdm_dataportal/includes/pages.inc
index 7ff8c5d1..3e4d605d 100755
--- a/modules/cdm_dataportal/includes/pages.inc
+++ b/modules/cdm_dataportal/includes/pages.inc
@@ -586,7 +586,11 @@ function compose_cdm_taxon_page_profile($taxon, $merged_tree, $media, $add_synon
       $feature_description = make_pseudo_feature('Descriptions (aggregated)', PSEUDO_FEATURE_AGGREGATION_DESCRIPTIONS);
       $description_item = '';
       foreach ($aggregatedDescriptions as $description) {
-        $description_item .= render_cdm_description($description, TRUE);
+        $description_item = '<div class="' . html_class_attribute_ref($description) . '">';
+        $description_item .= render_description_string($description, get_root_nodes_for_dataset($description));
+        $description_item .= ' ' . icon_link(path_to_description($description->uuid));
+        $description_item .= '<div class="content-caption">'. t('Bracketed numbers denote sample size') . '</div>';
+        $description_item .= '</div>';
       }
       $description_block = feature_block(t('Descriptions (aggregated)'), $feature_description);
       $description_block->content = [];
