I have a data.table with about 3 million rows and 40 columns. I would like to sort this table by descending order within groups like the following sql mock code:
The comment was mine, so I'll post the answer. I removed it because I couldn't test whether it was equivalent to what you already had. Glad to hear it's faster.
X <- X[order(Year, MemberID, -Month)]
Summarizing shouldn't depend on the order of your rows.