Partial quicksort.
install
npm install pqsort --save-prod
Usage
const pqsort = var t1 = var t2 = /** Here we construct an object `{value: value, data: index}` to keep the sorted index under the `data` attribute. You may put anything under the `data` attribute. The sorting will be performed on the `value` attribute. **/ { return arr} // sort the 3 minimum values in the array and put them at the beginning/* t1 = [ { data: 8, value: 0 }, { data: 6, value: 1 }, { data: 3, value: 2 }, ...] */ // sort 10 values in the array (all of them)/* t2 = [{ data: 8, value: 0 }, { data: 6, value: 1 }, { data: 3, value: 2 }, { data: 9, value: 3 }, { data: 2, value: 4 }, { data: 0, value: 5 }, { data: 5, value: 6 }, { data: 1, value: 7 }, { data: 4, value: 8 }, { data: 7, value: 9 }] */
TODO
- self-defined comparision function