Skip to content

Instantly share code, notes, and snippets.

@hperrin
Created March 14, 2018 01:26

Revisions

  1. hperrin revised this gist Mar 14, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Array.prototype.insertInOrder = function(item) {
    for (var i = 0; this[i] < item && i < this.length; i++);
    this.splice(i, 0, item);
    for (var i = 0; this[i] < item && i < this.length; i++);
    this.splice(i, 0, item);
    };
  2. hperrin created this gist Mar 14, 2018.
    4 changes: 4 additions & 0 deletions index.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    Array.prototype.insertInOrder = function(item) {
    for (var i = 0; this[i] < item && i < this.length; i++);
    this.splice(i, 0, item);
    };