diff --git a/bids-validator/src/schema/expressionLanguage.ts b/bids-validator/src/schema/expressionLanguage.ts index f5e2bd1e8..41823f494 100644 --- a/bids-validator/src/schema/expressionLanguage.ts +++ b/bids-validator/src/schema/expressionLanguage.ts @@ -88,8 +88,8 @@ export const expressionFunctions = { return arg.substr(start, end - start) }, sorted: (list: T[]): T[] => { - // Copy, sort, return - return list.slice().sort() + // Use a cmp function that will work for any comparable types + return list.toSorted((a, b) => +(a > b) - +(a < b)) }, allequal: (a: T[], b: T[]): boolean => { return (a != null && b != null) && a.length === b.length && a.every((v, i) => v === b[i])