Fixes #648
This commit is contained in:
parent
bc9d75fcae
commit
a4b5d6cabe
@ -1,9 +1,8 @@
|
|||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import naturalSort from 'natural-sort';
|
import naturalSort from 'natural-sort';
|
||||||
|
|
||||||
export default (sortableArray: Object[], key: string) => {
|
export default (sortableArray: Object[] = [], key: string) => {
|
||||||
let keys = sortableArray.map(object => object[key]);
|
let keys = sortableArray.map(object => object[key]);
|
||||||
keys.sort(naturalSort());
|
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