Implementation of BSD system's qsort in javascript (Copied from https://github.com/inspirit/jsfeat )