UNPKG

@kuzanatoliorg/algorithms

Version:

The utils package for react testing library

23 lines (22 loc) 694 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.combSort = void 0; const utils_1 = require("../utils"); const SHRINK = 1.247; const combSort = (arr, comparator = utils_1.defaultComparator, order = true) => { let j, sh = arr.length, item; while (sh > 1) { sh = Math.floor(sh / SHRINK); for (j = 0; j + sh < arr.length; j++) { if (order ? comparator(arr[j + sh], arr[j]) : comparator(arr[j], arr[j + sh])) { item = arr[j]; arr[j] = arr[j + sh]; arr[j + sh] = item; } } } return arr; }; exports.combSort = combSort;