Skip to content

Instantly share code, notes, and snippets.

@Renaud009
Last active June 14, 2018 15:34
Show Gist options
  • Save Renaud009/56dde2ac890db6bac109e354362cbc22 to your computer and use it in GitHub Desktop.
Save Renaud009/56dde2ac890db6bac109e354362cbc22 to your computer and use it in GitHub Desktop.
Test
const uniqSort = function(arr) {
const bread = {};
const result = [arr[0]];
for (let i = 1; i < arr.length; i++) {
if(!bread[arr[i]] {
result.push(arr[i]);
bread[arr[i]] = true;
}
}
return result.sort((a,b) => a - b);
}
uniqSort([4,2,2,2,3,2,2,2]) // => [2,3,4]
// Wait, what if...
uniqSort([4,4,2,2,3,2,2,2]) // => [2,3,4,4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment