Think I already found the answer. The local deployment uses HSQLDB and the public sandbox is a Postgresql db:
https://docs.mendix.com/refguide/case-sensitive-database-behavior
But more specifically it seems to be an issue with differences in collation between the two. Because I’m running locally on a windows machine and the cloud node is most likely a unix system, they probably have different collations, which can lead to different sorting results, even if the same DB is used (e.g. Postgresql):
https://stackoverflow.com/questions/31924829/postgresql-order-by-returning-two-different-orders/31925591#31925591
I’m going to try and see if I can do a retrieve and then use the “List Sort” activity to get the same sort result across both locally and sandbox deploys.
Yes, the List Sort action solved this for me. Most likely because it’s using Java to do the sorting vs. the underlying DB.