From c782a22591e46c41b3be9a17a49065afc39a6817 Mon Sep 17 00:00:00 2001
From: Thijs Kinkhorst <thijs@kinkhorst.com>
Date: Mon, 11 Jun 2018 19:48:12 +0000
Subject: [PATCH] IdpDisco: make sorting case insensitive and apply it also to
 the 'links' variant

---
 templates/selectidp-dropdown.php | 2 +-
 templates/selectidp-links.php    | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/templates/selectidp-dropdown.php b/templates/selectidp-dropdown.php
index a3c4d2bf1..3f473b735 100644
--- a/templates/selectidp-dropdown.php
+++ b/templates/selectidp-dropdown.php
@@ -34,7 +34,7 @@ foreach ($this->data['idplist'] as $idpentry) {
         <select id="dropdownlist" name="idpentityid">
             <?php
             usort($this->data['idplist'], function ($idpentry1, $idpentry2) {
-                return strcmp(
+                return strcasecmp(
                     $this->t('idpname_'.$idpentry1['entityid']),
                     $this->t('idpname_'.$idpentry2['entityid'])
                 );
diff --git a/templates/selectidp-links.php b/templates/selectidp-links.php
index b8f2d6e3d..5a6b0c359 100644
--- a/templates/selectidp-links.php
+++ b/templates/selectidp-links.php
@@ -34,6 +34,12 @@ foreach ($this->data['idplist'] as $idpentry) {
             }
             ?></p>
 <?php
+        usort($this->data['idplist'], function ($idpentry1, $idpentry2) {
+            return strcasecmp(
+                $this->t('idpname_'.$idpentry1['entityid']),
+                $this->t('idpname_'.$idpentry2['entityid'])
+            );
+        });
         if (!empty($this->data['preferredidp']) &&
             array_key_exists($this->data['preferredidp'], $this->data['idplist'])
         ) {
-- 
GitLab