Fix ProfilerStandard sorting and a profile error

* Sort $this->collated even if collateOnly is set. Also I don't think
  arsort works that way.
* Fix a profiling error in every DB query, which was due to the two
  scoped profiling sections being destroyed in the wrong order.

Change-Id: I6af05f37a5c0391acfa80d54ecbca7a08ad81250