Smarter ResultSet::applySorting()