UNPKG

@clarketm/superbubblesort

Version:
7 lines • 933 B
/** * Copyright (c) 2018, Travis Clarke * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ !function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(e.BubbleSort={})}(this,function(e){"use strict";function r(e,r){return e-r}function t(e){return function(r,t){return e(r,t)<0}}function n(e,r,t){if(r!==t){var n=[e[t],e[r]];e[r]=n[0],e[t]=n[1]}}function i(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r;if(!(this instanceof Array||e instanceof Array))throw Error("Array type is required");var o=this instanceof Array?this:e.slice(0),f=t(i);return function(e){for(var r=0;r<e.length-1;r++){for(var t=!1,i=0;i<e.length-r-1;i++)f(e[i+1],e[i])&&(t=!0,n(e,i+1,i));if(!t)break}return e}(o)}e.bubbleSort=i,Object.defineProperty(e,"__esModule",{value:!0})});