sorting-algorithms-lib
Version:
sorting-algorithms-lib is a lightweight JavaScript library that provides efficient implementations of various sorting algorithms. Whether you're learning algorithms, benchmarking performance, or building a project that requires sorting, this library has y
15 lines (14 loc) • 471 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.swap = swap;
/**
* Given an array, swaps two elements at the specified positions (indices).
* @param array Array in which to swap elements between two positions
* @param pos1 Index of first element's position
* @param pos2 Index of second element's position
*/
function swap(array, pos1, pos2) {
let temp = array[pos1];
array[pos1] = array[pos2];
array[pos2] = temp;
}