Closes #686 - null does not trigger default param
This commit is contained in:
@ -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]));
|
||||
};
|
||||
|
Reference in New Issue
Block a user