Why does my mail show out of order on my iPhone or iPad?

This page is showing a generic answer.
To see a more detailed answer customized for you, type your e-mail address here:

When the iOS Mail app displays messages, it doesn’t try to sort the messages by date like most mail programs. Instead, it simply shows you the messages in the order they’re listed on the mail server.

In most cases, this isn't a problem because the server lists messages in the order they were added to each folder, so the most recent one shows at the end of the list as you’d expect. If you move old messages between folders, though, those messages will show up at the end of the list, even if you don’t want them to show there because they’re old.

If this bothers you, you can contact us and ask us to re-order the list of messages on the server for you. As long as you only use IMAP and not POP3 to access your mail, this will work fine; iOS and other IMAP mail programs will simply show you the messages in the new order. You probably won’t want to do this on your Inbox if you use POP3 to access your mail on any other devices, though, because the change can make POP3 mail programs think each message is new and download a second copy of all your mail.

How to fix this from the command line shell

If you ask us to fix this for you, we’ll run the commands shown below from the command line shell. Technically advanced users who are comfortable using the shell can do it themselves if they prefer:

cd ~/mailstore/address
rm -fv dovecot-uid*
imap-cache-reset address@example.com

The commands above assume you want to reorder the messages in the Inbox. If it’s for another folder, you would cd to that folder first:

cd ~/mailstore/address
cd .OtherFolder
rm -fv dovecot-uid*
imap-cache-reset address@example.com

Doing this does not delete any useful data. It merely makes the next IMAP connection build a new dovecot-uidlist file on the server with the messages in the order of their filenames, which should be the order each message was received. That new order is then sent to the mail program, which will probably be slower for the next connection but should return to normal speed after that.