optimized sorting for documents - frontend