allow usage of zend-qsort in user sorts with a runtime option

Summary: uasort/usort don't impose a strict order, and because HHVM and PHP use a
different sorting algorithm this means that in some cases we can end up
with different results.

This commit allows us to fall back to standard zend qsort behavior
(which is used by Array::sortImpl) when doing sorting through user-defined
compare functions.

More information can be found in an earlier (incorrect) pull request:
https://github.com/facebook/hhvm/pull/2484#issuecomment-42093840

If you have any questions, paroski should be able to clarify.

Fixes 5 zend tests, and closes the following github issues:
Closes #2484.
Closes #2416.
Closes #1781.
Closes #2749

Reviewed By: @ptarjan

Differential Revision: D1347291

Pulled By: @JoelMarcey
Merge pull request #2805 from danslo/3.1.0-qsort

cherrypicked qsort patch on 3.1