Permalink
Browse files

Adding a unique sort extension for the array prototype.

  • Loading branch information...
1 parent 7530cd8 commit 57a214e1bfc13f889e58de2956947d3266f8b4fe @simonwex simonwex committed Aug 8, 2012
Showing with 11 additions and 0 deletions.
  1. +11 −0 lib/extensions/array.js
View
@@ -0,0 +1,11 @@
+Array.uniqueSort = function(a) {
+ a.sort();
+
+ for (var i = 1; i < a.length; i++){
+ if(a[i] === a[i-1]){
+ a.splice(i--, 1);
+ }
+ }
+
+ return a;
+};

0 comments on commit 57a214e

Please sign in to comment.