Improve sort order and remove list header that's inaccurate now
This commit is contained in:
parent
1302d91469
commit
7d9993b158
3 changed files with 26 additions and 7 deletions
|
|
@ -7,11 +7,30 @@ export function filePath(path) {
|
|||
};
|
||||
|
||||
// MARK: documentSorter
|
||||
/**
|
||||
* @typedef {Object} Sortable
|
||||
* @property {integer} sort
|
||||
* @property {string} name
|
||||
*/
|
||||
|
||||
/**
|
||||
* Compares two Sortable documents in order to determine ordering
|
||||
* @param {Sortable} a
|
||||
* @param {Sortable} b
|
||||
* @returns An integer dictating which order the two documents should be sorted in
|
||||
*/
|
||||
export function documentSorter(a, b) {
|
||||
if (!a && !b) {
|
||||
return 0;
|
||||
} else if (!a) {
|
||||
return 1;
|
||||
} else if (!b) {
|
||||
return -1;
|
||||
};
|
||||
|
||||
const sortDelta = b.sort - a.sort;
|
||||
if (sortDelta !== 0) {
|
||||
return sortDelta;
|
||||
};
|
||||
// TODO alphabetical sort
|
||||
return 0;
|
||||
return Math.sign(a.name.localeCompare(b.name));
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue