code: function stableSort(fn) {
  		var type = typeOf(this[0]);
  
  		if (type == "Number" || type == "String") {
  			var ord = {}, len = this.length, val;
  
  			for (var i = 0; i < len; i++) {
  				val = this[i];
  				if (ord[val] || ord[val] === 0) continue;
  				ord[val] = i;
  			}
  
  			return this.sort(function(a,b) {
  				return fn(a,b) || ord[a] - ord[b];
  			});
  		}
  		else {
  			var ord = this.map(function(v){return v});
  
  			return this.sort(function(a,b) {
  				return fn(a,b) || ord.indexOf(a) - ord.indexOf(b);
  			});
  		}
  	}
docs: must be used via stableSort.call(arr, fn)