Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SortBy with deep object access
'use strict';
function deep(obj, prop) {
var segs = prop.split('.');
while (segs.length) {
obj = obj[segs.shift()];
return obj;
module.exports = function(prop) {
return function(item) {
return deep(item, prop);
// Usage:
var deep = require('deep'); // `deep` being the above
_.sortBy(arr, deep('some.nested.key'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.