Refactor IMAP SORT command support to use the extension API.