I am encountering an issue with sorting dates in a DataTable. The DataTable structure is as follows:
<DataTable
:rows = "5"
:value = "apiItems"
>
<Column
:field="initialDate"
:header="Initial Date"
:sortable="true"
/>
<Column
:field="finishDate"
:header="Finish Date"
:sortable="true"
/>
</DataTable>
The data fields 'initialDate' and 'finishDate' are retrieved from an API call and contain date-time values like "08/21/2022 11:43:12". However, when attempting to sort these columns, the sorting is based on the first number in the string (the month) rather than the actual date.
EXPECTED SORTING BEHAVIOR:
Ascending:
"07/01/2022 12:01:09"
"08/22/2021 11:43:12"
ATTEMPTS MADE:
I have tried converting the date strings into JavaScript Date objects using new Date(initialDate).toLocaleString(), but the sorting issue persists.
Any help or suggestions on resolving this would be greatly appreciated. Thank you for your assistance.