Created
May 6, 2015 12:48
-
-
Save itrelease/fb782b3555bb134625d7 to your computer and use it in GitHub Desktop.
sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function sort(arr) { | |
var tmp = []; | |
var sorted = []; | |
var i, l; | |
var ii, ll; | |
for (i=0, l=arr.length; i<l; i++) { | |
var value = arr[i]; | |
if (!tmp[value]) { | |
tmp[value] = 0; | |
} | |
tmp[value] += 1; | |
} | |
for (i=0, l=tmp.length; i<l; i++) { | |
if (typeof tmp[i] !== 'undefined') { | |
for (ii=0, ll=tmp[i]; ii<ll; ii++) { | |
sorted.push(i); | |
} | |
} | |
} | |
return sorted; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment