Skip to content

Instantly share code, notes, and snippets.

const qsort = (arr) => {
if (arr.length < 2) {
return arr;
} else {
// Опорная точка для деления массива, выбирается случайно
const pivotPosition = Math.floor(Math.random() * arr.length);
const pivot = arr[pivotPosition];
// Значения меньшие, либо равные опорному
// попадают в новый массив less
const less = arr.filter((value, index) => {