static-cms/src/formats/helpers.js
Caleb 2ef6556d4a Add support for TOML files. (#740)
* Move `sortKeys` into a helper function.

* Add support for TOML files.
2017-10-26 11:43:28 -07:00

14 lines
313 B
JavaScript

export const sortKeys = (sortedKeys = []) => (a, b) => {
const idxA = sortedKeys.indexOf(a);
const idxB = sortedKeys.indexOf(b);
if (idxA === -1 || idxB === -1) {
if (a > b) return 1;
if (a < b) return -1;
return 0;
}
if (idxA > idxB) return 1;
if (idxA < idxB) return -1;
return 0;
};