UNPKG

node-sort

Version:

A sorting library for Node.js

22 lines (19 loc) 770 B
var Sort = require("..") , sort = new Sort(); var unsorted1 = [] , unsorted2 = [] , unsorted3 = [] , unsorted4 = [] , unsorted5 = []; for(var i = 0; i < 20; i++) { unsorted1.push(Math.round(Math.random() * 100)); unsorted2.push(Math.round(Math.random() * 100)); unsorted3.push(Math.round(Math.random() * 100)); unsorted4.push(Math.round(Math.random() * 100)); unsorted5.push(Math.round(Math.random() * 100)); } console.log("Merge Sort: " + sort.mergeSort(unsorted1, null)); console.log("Bubble Sort: " + sort.bubbleSort(unsorted2, null)); console.log("Selection Sort: " + sort.selectionSort(unsorted3, null)); console.log("Insertion Sort: " + sort.insertionSort(unsorted4, null)); //console.log("Bucket Sort: " + sort.bucketSort(unsorted5, null));