Skip to content

Commit

Permalink
Merge pull request #1878 from Agenta-AI/AGE-419/-localeCompare-is-not…
Browse files Browse the repository at this point in the history
…-a-function

[Bug] TypeError: e.localeCompare is not a function
  • Loading branch information
aakrem authored Jul 15, 2024
2 parents aaa9008 + 4139b7e commit 7357d2d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions agenta-web/src/lib/helpers/evaluate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,10 +333,20 @@ const getCustomComparator = (type: CellDataType) => (valueA: string, valueB: str
const num = parseFloat(val || "0")
return isNaN(num) ? 0 : num
}
if (type === "date") return dayjs(valueA).diff(dayjs(valueB))
if (type === "text") return valueA.localeCompare(valueB)
if (type === "number") return getNumber(valueA) - getNumber(valueB)
return 0

valueA = String(valueA)
valueB = String(valueB)

switch (type) {
case "date":
return dayjs(valueA).diff(dayjs(valueB))
case "text":
return valueA.localeCompare(valueB)
case "number":
return getNumber(valueA) - getNumber(valueB)
default:
return 0
}
}

export const removeCorrectAnswerPrefix = (str: string) => {
Expand Down

0 comments on commit 7357d2d

Please sign in to comment.