You can combine dedup and sort by using the 'sortby' keyword in the dedup command, e.g.
dedup x sortby y
Also, another caveat with dedup is that it could use unlimited memory for a high cardinality field (like some sort of unique identifier, e.g. ip address, cookie, etc)
EDIT:: adding in paraphrased version of 2 other comments that steveyz made on this topic via IM:
About ordering, fields should always be first. It's like pushing selection as early as possible. Things like fields, where, search, etc. Should be as early as possible
There are probably scenarios where dedup first might be a little faster, but that should be the edge case
... View more