Sort.bubbleSort()

Sort an array using Bubble sort algorithm

Time complexity is O(n2)

Usage

Hover over inputs/exits for more info.

var Sort = require('machinepack-sort');


// Sort an array using Bubble sort algorithm

Sort.bubbleSort({

array: [ 5, 3, 1, 4, 2 ],

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// OK.

success: function (sortedArray) {

 

},

});

Inputs

array required

Array to be sorted.

[ 5, 3, 1, 4, 2 ]

Exits

error

An unexpected error occurred.

success

OK.

[ 1, 2, 3, 4, 5 ]