Skip to content

Instantly share code, notes, and snippets.

@indefinitelee
Created June 16, 2018 17:15
Show Gist options
  • Save indefinitelee/93700fdf7c68943ddc619d248e9318e3 to your computer and use it in GitHub Desktop.
Save indefinitelee/93700fdf7c68943ddc619d248e9318e3 to your computer and use it in GitHub Desktop.
MajorLikableCases created by indefinitelee1 - https://repl.it/@indefinitelee1/MajorLikableCases
const uniqSort = function(arr) {
const memo = {[arr[0]] : true};
const result = [arr[0]];
for (let i = 1; i < arr.length; i++) {
if (!memo[arr[i]]) {
result.push(arr[i]);
memo[arr[i]] = true;
}
}
return result.sort((a,b) => a - b);
}
uniqSort([4,2,2,3,3,3,3,2,2,4])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment