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

@@ -1,7 +1,7 @@
// @flow
import _ from 'lodash';
import { Collection } from '../models';
import presentDocument from './document';
import naturalSort from '../../shared/utils/naturalSort';
type Document = {
children: Document[],
@@ -11,7 +11,7 @@ type Document = {
};
const sortDocuments = (documents: Document[]) => {
const orderedDocs = _.sortBy(documents, ['title']);
const orderedDocs = naturalSort(documents, 'title');
return orderedDocs.map(document => ({
...document,
children: sortDocuments(document.children),