From 9fcbe5c6789976afab0e6db959cb6e38d3f1f7c4 Mon Sep 17 00:00:00 2001
From: Rapptz <rapptz@gmail.com>
Date: Thu, 23 Mar 2017 19:34:36 -0400
Subject: [PATCH] Sort Guild.text_channels and Guild.voice_channels in UI
 order.

---
 discord/guild.py | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/discord/guild.py b/discord/guild.py
index 760632bce..021648d60 100644
--- a/discord/guild.py
+++ b/discord/guild.py
@@ -262,8 +262,13 @@ class Guild(Hashable):
 
     @property
     def voice_channels(self):
-        """List[:class:`VoiceChannel`]: A list of voice channels that belongs to this guild."""
-        return [ch for ch in self._channels.values() if isinstance(ch, VoiceChannel)]
+        """List[:class:`VoiceChannel`]: A list of voice channels that belongs to this guild.
+
+        This is sorted by the position and are in UI order from top to bottom.
+        """
+        r = [ch for ch in self._channels.values() if isinstance(ch, VoiceChannel)]
+        r.sort(key=lambda c: c.position)
+        return r
 
     @property
     def me(self):
@@ -275,8 +280,13 @@ class Guild(Hashable):
 
     @property
     def text_channels(self):
-        """List[:class:`TextChannel`]: A list of text channels that belongs to this guild."""
-        return [ch for ch in self._channels.values() if isinstance(ch, TextChannel)]
+        """List[:class:`TextChannel`]: A list of text channels that belongs to this guild.
+
+        This is sorted by the position and are in UI order from top to bottom.
+        """
+        r = [ch for ch in self._channels.values() if isinstance(ch, TextChannel)]
+        r.sort(key=lambda c: c.position)
+        return r
 
     def get_channel(self, channel_id):
         """Returns a :class:`abc.GuildChannel` with the given ID. If not found, returns None."""