CONTRIB-4798: Now sorting by section position rather than id

Fixed CONTRIB-4798: https://tracker.moodle.org/browse/CONTRIB-4798
There's certainly a smarter way to do this, but at least it works :)