Refactor data sorting in a pseudo database interface