Closes #686 - null does not trigger default param

This commit is contained in:
Tom Moor
2018-09-30 18:42:27 -07:00
parent d54750ef19
commit 1356e35ad1

View File

@ -1,9 +1,11 @@
// @flow
import _ from 'lodash';
import { sortBy } from 'lodash';
import naturalSort from 'natural-sort';
export default (sortableArray: Object[] = [], key: string) => {
export default (sortableArray: Object[], key: string) => {
if (!sortableArray) return [];
let keys = sortableArray.map(object => object[key]);
keys.sort(naturalSort());
return _.sortBy(sortableArray, object => keys.indexOf(object[key]));
return sortBy(sortableArray, object => keys.indexOf(object[key]));
};