From 7dd3f31416fe2b7658bc98774fe98d6065564767 Mon Sep 17 00:00:00 2001
From: dereine <dereine@99340.no-reply.drupal.org>
Date: Sun, 22 Jul 2012 22:31:25 +0200
Subject: [PATCH] Issue #1331272 by dawehner | mototribe: Added Global: View
 Area sorting.

---
 handlers/views_handler_area_view.inc | 2 +-
 views.module                         | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/handlers/views_handler_area_view.inc b/handlers/views_handler_area_view.inc
index aee16653b340..45ea49998d6d 100644
--- a/handlers/views_handler_area_view.inc
+++ b/handlers/views_handler_area_view.inc
@@ -30,7 +30,7 @@ function options_form(&$form, &$form_state) {
     $view_display = $this->view->name . ':' . $this->view->current_display;
 
     $options = array('' => t('-Select-'));
-    $options += views_get_views_as_options(FALSE, 'all', $view_display);
+    $options += views_get_views_as_options(FALSE, 'all', $view_display, FALSE, TRUE);
     $form['view_to_insert'] = array(
       '#type' => 'select',
       '#title' => t('View to insert'),
diff --git a/views.module b/views.module
index 32d5739d111b..f044f859c605 100644
--- a/views.module
+++ b/views.module
@@ -1486,12 +1486,14 @@ function views_get_disabled_views() {
  * @param bool $optgroup
  *  If TRUE, returns an array with optgroups for each view (will be ignored for
  *  $views_only = TRUE). Can be used by select
+ * @param bool $sort
+ *  If TRUE, the list of views is sorted ascending.
  *
  * @return array
  *  an associative array for use in select.
  *  - key: view name and display id separated by ':', or the view name only
  */
-function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclude_view = NULL, $optgroup = FALSE) {
+function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclude_view = NULL, $optgroup = FALSE, $sort = FALSE) {
 
   // Filter the big views array.
   switch ($filter) {
@@ -1538,6 +1540,9 @@ function views_get_views_as_options($views_only = FALSE, $filter = 'all', $exclu
       }
     }
   }
+  if ($sort) {
+    ksort($options);
+  }
   return $options;
 }
 
-- 
GitLab