Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
20 lines
619 B
Plaintext
20 lines
619 B
Plaintext
function getAccessor(field) {
|
|
return field.accessor ?? ('name' in field ? field.name : undefined);
|
|
}
|
|
export function sortFieldMap(fieldMap, sortTo) {
|
|
return fieldMap?.sort((a, b) => {
|
|
const aIndex = sortTo.findIndex(column => 'name' in a && column.accessor === getAccessor(a));
|
|
const bIndex = sortTo.findIndex(column => 'name' in b && column.accessor === getAccessor(b));
|
|
if (aIndex === -1 && bIndex === -1) {
|
|
return 0;
|
|
}
|
|
if (aIndex === -1) {
|
|
return 1;
|
|
}
|
|
if (bIndex === -1) {
|
|
return -1;
|
|
}
|
|
return aIndex - bIndex;
|
|
});
|
|
}
|
|
//# sourceMappingURL=sortFieldMap.js.map |