algosort
Version:
This node package is for all javascript developers who are interested in sorting algorithms. This package gives you the possibility to choose between many different sorting algorithms. This package will output a two dimensional array of all numbers in dif
21 lines (18 loc) • 850 B
JavaScript
const bubblesortAlgorithm = require('../algorithms/bubblesort.js');
const selectionsortAlgorithm = require('../algorithms/selectionsort.js');
function algosort(options) {
if (options.algorithm == null)
options.algorithm = `bubblesort`;
if (options.output == null)
options.output = `afterEachNumber`;
if (options.numbers != null)
if (options.algorithm === `bubblesort`)
return bubblesortAlgorithm.bubblesort(options.numbers, 0, options.output, 0);
else if (options.algorithm === `selectionsort`)
return selectionsortAlgorithm.selectionsort(options.numbers, 0, options.output, 0);
else
return `There is no algorithm called ${options.algorithm}! \n\n Algorithm options: "bubblesort" and "selectionsort"`;
else
return `You need to enter an array of numbers!`;
}
module.exports.algosort = algosort;