Added natural sorting for documents and collections

This commit is contained in:
Jori Lallo
2018-02-28 23:00:41 -08:00
parent 9142d975df
commit 4bc8a152c1
5 changed files with 20 additions and 4 deletions

View File

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