Sort Gmail by Subject, Labels and Sender to Organize Your Inbox


One feature, I often miss in Gmail is its ability to sort messages. By default, Gmail sorts mails by date, which doesn’t do a great job in organizing your inbox. There is no facility to sort mails by name, subject, size and sender. Consider this scenario where sorting of mails can be very useful : You were on vacation and on returning found thousands of unread mails, and now you want to see only the unread messages by your boss between the specific dates.

One thing to note that Gmail is based on search and not sort, therefore things have to be done here in different ways. Let us look how you can sort Gmail messages:

Sort Gmail by Subject
To sort your mails by subject, copy-paste the below code into the address bar and press enter. In Chrome, you will have to go to Console (Presee F12) and paste his code. This code will only sort the current set of mails that you are viewing.

Credit : Snipplr

Please note that Gmail frequently changes its backend HTML code and therefore this javascript may not always work.

Sort Gmail by Labels
In Gmail, you can drag-and-drop a label, which makes labelling quite easy. You can also select which labels to show and which one to hide from Gmail’s settings page. However, unlike outlook that arranges folders automatically there is no such sorting facility in Gmail.

This greasemonkey script lets you sort labels as you last used them. Example: From the set of labels X,Y and Z suppose you recently used Y. So, the labels will be sorted by Y,X and Z.
You can download this script here. (and you must have greasemonkey firefox addon to use it)

Sort Gmail by Sender
Gmail has already provided this feature however with a different name, Recent Conversations. Hover over any name and select recent conversations to view all incoming(received) or outgoing(sent) mails with selected name. To view only received mails, search with from:sender’s name in Gmail inbox. Find the complete tutorial here.

Sort Gmail by Size
As organize by size cannot be done directly in gmail, you can use Outlook or Thunderbird (email clients) to import your mails and then sort them by size. [Importing Instructions]. Since there is no way you can sort Gmail by size of mails, you can however use the search operator “has:attachment” to find all the large size mails.

You can also search for “filename:mp3” or “filename:pdf” or any files that you regularly receive to find the large size mails.

Bonus tip: For those, whose inbox memory is full:

Though Gmail provide hundreds of thousands of inbox memory (at present 7400MB), then to you can run out of space. In such a case search for “has:attachment from:me label:sent” which will list mails sent by you and have a attachment. You can safely delete them to get some extra space.

How to Search for Mails within Specific Date
Gmail by default sort mails by date. To find mails between specific dates in Gmail, you will have to do an advance search. Click on “Show search option” beside Gmail search box and then choose “Date within” search criteria. There is no field for “From” and “To” date to search however entering only one date and then selecting date within range will give same results.


Sort Read and Unread Mails
There is no sorting available to sort unread mails first and then read one with a simple operation like in yahoo mail. But you can do two different searches to find all the read and unread mails sorted by date.

To search all unread mail, enter “is:unread” in the Gmail searc box. Similarly, enter “is:read” to search for all read mails.

Sort Incoming Mails with Filters
You probably know that, you can use Gmail id with a plus (+) to create a new version of your account. Suppose your email id is Now, even if you subscribe any website with , then to all the mails will come to you only. You can create as many versions you want by appending any word with your username with plus (+) symbol.
Now the tricks is to use Filters with this feature to sort different types of incoming mails.

Conclusion: Gmail is Based on Search Not Sort
Gmail is different from the regular mail clients like outlook or yahoo. It’s a very powerful application, if only you can learn to search and make proper filters. Here are some of the search operators that you will find useful in daily life.

Operator Definition Example(s)
from: Used to specify the
Example – from:amy
Meaning – Messages from Amy
to: Used to specify a recipient Example – to:david

Meaning – All messages that were sent to David (by you or someone else)

subject: Search for words in the subject line Example – subject:dinner

Meaning – Messages that have
the word “dinner” in the subject

OR Search for messages matching term A or term B*
*OR must be in all
Example – from:amy OR from:david
Meaning – Messages from Amy or from David

Used to exclude messages from your search Example – dinner -movie
Meaning – Messages that contain the word “dinner” but do not contain
the word “movie”
label: Search
for messages by label*
*There isn’t a search operator for unlabeled messages
Example – from:amy label:friends
Meaning – Messages from Amy that
have the label “friends”

Example – from:david label:my-family

Meaning – Messages from David that
have the label “My Family”

has:attachment Search for
messages with an attachment
Example –

from:david has:attachment
Meaning – Messages from David that have
an attachment

list: Search for messages on mailing lists Example –

Meaning – Messages with the words in the headers, sent to or from this list

filename: Search for an attachment by name or type Example –

Meaning – Messages with an
attachment named “physicshomework.txt”

Example –
label:work filename:pdf

Meaning – Messages labeled
“work” that also have a PDF file as an attachment

” ”
Used to search for an exact phrase*
*Capitalization isn’t taken into consideration
Example –
“i’m feeling lucky”

Meaning – Messages containing
the phrase “i’m feeling lucky” or “I’m feeling lucky”

Example –
subject:”dinner and a movie”

Meaning – Messages containing
the phrase “dinner and a movie” in the subject

( ) Used to group words
Used to specify terms that shouldn’t be excluded
Example –
from:amy(dinner OR movie)

Meaning – Messages from Amy
that contain either the word “dinner” or the word “movie”

Example –
subject:(dinner movie)

Meaning – Messages in which
the subject contains both the word “dinner” and the word “movie”

in:anywhere Search for messages anywhere in Gmail*
*Messages in Spam and Trash are excluded from searches
by default
Example – in:anywhere

Meaning – Messages in All Mail,
Spam, and Trash that contain the word “movie”
Search for messages in Inbox, Trash, or Spam Example – in:trash

Meaning – Messages from Amy that
are in Trash


Search for messages that are starred, unread or read Example –
is:read is:starred from:David

Meaning – Messages from David that
have been read and are marked with a star

Used to specify recipients in the cc: or bcc: fields*

*Search on bcc: cannot retrieve messages on which you were blind carbon copied

Example –

Meaning – Messages that were cc-ed to David


Search for messages sent
during a certain period of time*
*Dates must be in yyyy/mm/dd format.
Example –
after:2004/04/16 before:2004/04/18

Meaning – Messages sent between April 16, 2004 and April 18, 2004.*
*More precisely: Messages sent after 12:00 AM (or 00:00) April 16, 2004 and before April 18, 2004.

is:chat Search for chat messages Example –

is:chat monkey
Meaning – Any chat message including the word “monkey”.

deliveredto: Search for messages within a particular email address in the Delivered-To line of the message header Example –

Meaning – Any message with in the Delivered-To: field of the message header (which can help you find messages forwarded from another account or ones sent to an alias).

[From Google support]

Related : Best Gadgets for Gmail

Filed under Gmail Tricks. Posted by Abhishek and last updated on November 11, 2012.

Comments are closed.

Thanks for the share.. Coding is the best part which i always love to play with..

Abhishek, thanks for the detailed information, it is really informative.

What an amazing number of posts, both hear and at myriad other sites, discussing a workaround for a dirt simple feature that should have been in GMail right from the start. I mean having to write code for a simple sort? Really??

Does Google ever read any of this?

Superb workarounds. But the point is, they are still workarounds. I am so gutted to have given all my mates my gmail email as my primary, I am sorely tempted to relocate to yahoo and just do an email-all to let them know the new address. Surprising how cra p google’s email product is, particularly given how good their other products are.

Google doesn’t allow SORT because of their Google Adwords business model. If they allowed you to Sort, they wouldn’t be as able to serve up targeted ads to you based on your search query.

I think this is a pathetic business model however, because removing the capability to Sort email makes email about 60% less useful. Having to remember what to “Search” for really is a backwards way to find emails you need.

Well that explains it pretty well and helps me decide that I’m going to have to lose GMail altogether.

Everything else about Google products makes me want to go buy some of their stock. But this one leap into the abyss of computer gobbley-gook convinces me that maybe Google is no different than most organizations: there must be some idiots in very high positions, who somehow have concluded that it is all right to ignore what their customers want.

This comment is to Google development only, and likely unread, but just to clarify nothing personal to any individuals or their comments.

I understand the method used and I recently worked with individuals, just like the gmail developers, who were gung-ho, tally ho and yippie ki-yay in their insistance upon our private school’s switch from Outlook to Gmail until they screwed up by doing so and those individual Gmail inboxes were full of unsortable mail. Switched them back fast! Brilliant research and work!

I “get” that it’s a search and not a “sort” engine, but it doesn’t work for mail; making your client do the work you should have done makes gmail a “0” for efficiency.

Tried Gmail for about 30 days and can’t get used to not having folders, sort by date/subject/email address, etc. Gmail missed the boat and I’ll be back to using Yahoo email.

Labels are not the same as folders and it makes Gmail totally useless for 99% of the people that use it for work. Casual consumers may find it usable, but serious people won’t. So Google will be loosing who knows how many pair of eyes looking at email ads.

Another very annoying “feature” is that it saves you email in real time every second. I’m a fast typist and 100% of the time it misses letters as I type in when it saves.

I guess regressing back 20 years in email functionality is considered progress by Gmail. It’s time to fire their developers and hire ones that actually use it so they can listen to the users.

thank you for this info! I was so frustrated with gmail because of not being able to “mass delete” by sender…and now I can! much obliged!

Thank you so much.
This is very useful.

THANK YOU!!! Sorting by attachment is a lifesaver for my over quota mailbox!

This was very helpful!!!

Search Gmail Messages or emails by Sender

[…] have previously discussed how you can sort mails by size, labels and subject. But often we need to group similar mails to view the entire conversation from the specific sender […]

10 Power Tips for Gmail Attachments for Search, Sort and Everything

[…] really messy to keep track of these files. More ever, there is no sorting facility in Gmail to sort messages by size or attachments. But, Search facility can come to little use here. Here is a collection 10 power tips to keep track […]

Get Regular Google Updates