Glad to hear you guys don't have this problem in 4x!
I check to see if this bug was in ACES or ACS3.5 and it turns out that Eric Cholankeril wrote a PLSQL funtion (see packages/file-storage/file-storage.sql) that does the entire sort inside the database which is probably a better solution then my quick fix. If I find my quicky solution doesn't give me the performance I need I'll translate it for Postgres.