Faster pages sorting in O(n) database operations

I'm using an older version of the CMS with a tree of about 300 pages and the sorting functionality goes on for something like 2 minutes before completing.

The purpose of this pull request is mostly to discuss a new way of sorting pages by visiting the JSON tree that is provided as a param, assigning all the correct lft, rgt, depth and parent_id to these nodes and then just batch update all the pages to their correct marks.

This should take O(n) database operations and has reduced sorting locally from about 1:20 minutes to 28 seconds.

I do expect this solution to be considered hackish, and I do expect there to be potential concurrency problems, but I mostly want to have some feedback on this idea. 
Thanks!