lang/array.js
/**
		 * Inserts an item into an array using a binary search is used to determine the
		 * proper point for insertion and returns the same array.
		 *
		 * @static
		 * @public
		 * @param {Array} a
		 * @param {*} item
		 * @param {Function} comparator
		 * @returns {Array}
		 */
Inserts an item into an array using a binary search is used to determine the
proper point for insertion and returns the same array.


Inserts an item into an array using a binary search is used to determine the proper point for insertion and returns the same array .
insert(a, item, comparator) {
			assert.argumentIsArray(a, 'a');
			assert.argumentIsRequired(comparator, 'comparator', Function);
			if (a.length === 0 || !(comparator(item, a[a.length - 1]) < 0)) {
				a.push(item);
			} else if (comparator(item, a[0]) < 0) {
				a.unshift(item);
			} else {
				a.splice(binarySearchForInsert(a, item, comparator, 0, a.length - 1), 0, item);
			}
			return a;
		}
insert ( a , item , comparator ) { assert . argumentIsArray ( a , 'a' ) ; assert . argumentIsRequired ( comparator , 'comparator' , Function ) ; if ( a . length === 0 || ! ( comparator ( item , a [ a . length - 1 ] ) < 0 ) ) { a . push ( item ) ; } else if ( comparator ( item , a [ 0 ] ) < 0 ) { a . unshift ( item ) ; } else { a . splice ( binarySearchForInsert ( a , item , comparator , 0 , a . length - 1 ) , 0 , item ) ; } return a ; }
Inserts an item into an array using a binary search is used to determine the
 proper point for insertion and returns the same array.
Inserts an item into an array using a binary search is used to determine the proper point for insertion and returns the same array .