-
-
Save medfreeman/203b10bd9beef1d89a035b336bb038e4 to your computer and use it in GitHub Desktop.
Revisions
-
colingourlay revised this gist
Sep 23, 2014 . 2 changed files with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,9 @@ var obj = {b: 3, c: 2, a: 1}; _.sortKeysBy(obj); // {a: 1, b: 3, c: 2} _.sortKeysBy(obj, function (value, key) { return value; }); // {a: 1, c: 2, b: 3} This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ _.mixin({ 'sortKeysBy': function (obj, comparator) { var keys = _.sortBy(_.keys(obj), function (key) { return comparator ? comparator(obj[key], key) : key; }); return _.object(keys, _.map(keys, function (key) { -
colingourlay created this gist
Sep 22, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ _.mixin({ 'sortKeysBy': function (obj, comparator) { var keys = _.sortBy(_.keys(obj), function (key) { return comparator(obj[key], key); }); return _.object(keys, _.map(keys, function (key) { return obj[key]; })); } });