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
2016-05-07 15:28:32 +01:00

11 lines
281 B
JavaScript

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];
}));
}