As far as I understand your “value of a row” is meant to be some concateantion result starting with a date-time value.
You know that that concatenated date-time value only can be text the actual value was converted into using the TEXT function. (Otherwise, converted automatically, it would look like a decimal number.)
Dates, time values, and date-time values like general numerics, too, converted into text can only be sorted correctly if they are converted based on a strict format ensuring
- the more significant parts nearer to the front
- same length for all the values one part can have (except possibly trailing decimal places)
- no exponent parts
Back to Date-Time specifically:
The ISO 8601 standard (which is the only internationally recognised one) is made to exactly ensure the above conditions. You may use it slightly adapted to human preferences reading dates:
=TEXT(Date+Time;“YYYY-MM-DD HH:MM:SS”)&Delimiter&TheRestOfTheRow
(You may omit the “:SS” or - to the contrary - append “.00” for two decimals e.g. depending on the accuracy you want.)
am/pm is a deprecated remnant from very old times. An absolute no-go with this respect.