Implementing faster CMS pages sorting in O(n) database operations