How to check if values in the date/time list are sorted correctly

Hello,

I have a list of date/time values in format “6/10/21, 11:49 AM”. I can’t find appropriate way to check if values in the list are sorted by date/time correctly. Is there any RF library that could help me in this case or any other solution?
If I use “Sort List” keyword it is sorted as a string i.e. date/time is not sorted correctly.

I would appreciate any hint.

You probably have to create a keyword with an algorithm like:
(using DateTime Library)

My_serial_dates_list= List()
FOR i IN @{My_existing_list}
    Add to List   ${My_serial_dates_list}    Convert Date to Serial    ${i}
END

My_sorted_serial_dates_list= Sort    Copy of    ${My_serial_dates_list}

Should be Equal   ${My_serial_dates_list}     ${My_sorted_serial_dates_list}
1 Like

Thank you @HelioGuilherme66 for your answer that help me to find appropriate solution for my case. I actually convert my date/time to the epoch timestamp format and than sort list of the timestamps.

${timestamp} Convert Date ${dateTime} epoch date_format=%m/%d/%y, %I:%M %p

1 Like