This repository has been archived on 2023-03-26. You can view files and clone it, but cannot push or open issues or pull requests.
Sphere/app/helpers/sort-object.js

11 lines
281 B
JavaScript
Raw Normal View History

2016-05-07 15:28:32 +01:00
import _ from 'underscore';
export default function sortObject(obj, comparator) {
let keys = _.sortBy(_.keys(obj), function (key) {
return comparator ? comparator(obj[key], key) : key;
});
return _.object(keys, _.map(keys, function (key) {
return obj[key];
}));
}