From 80726bde82e8dcba918a202be9f6c9457df3ee30 Mon Sep 17 00:00:00 2001
From: Harrison Healey <harrisonmhealey@gmail.com>
Date: Mon, 18 Jul 2016 11:11:28 -0400
Subject: Sorted channels by name if their display_name is equal (#3607)

---
 webapp/components/sidebar.jsx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

(limited to 'webapp/components/sidebar.jsx')

diff --git a/webapp/components/sidebar.jsx b/webapp/components/sidebar.jsx
index 161f2fb7d..cd00c65dd 100644
--- a/webapp/components/sidebar.jsx
+++ b/webapp/components/sidebar.jsx
@@ -92,7 +92,7 @@ export default class Sidebar extends React.Component {
         const currentUserId = UserStore.getCurrentId();
 
         const channels = Object.assign([], ChannelStore.getAll());
-        channels.sort((a, b) => a.display_name.localeCompare(b.display_name));
+        channels.sort(this.sortChannelsByDisplayName);
 
         const publicChannels = channels.filter((channel) => channel.type === Constants.OPEN_CHANNEL);
         const privateChannels = channels.filter((channel) => channel.type === Constants.PRIVATE_CHANNEL);
@@ -363,6 +363,10 @@ export default class Sidebar extends React.Component {
     }
 
     sortChannelsByDisplayName(a, b) {
+        if (a.display_name === b.display_name) {
+            return a.name.localeCompare(b.name);
+        }
+
         return a.display_name.localeCompare(b.display_name);
     }
 
-- 
cgit v1.2.3-1-g7c22

