Changing date with crtl1 Change date eg. 10-06-2024 to '10-06-2024. Not working with sorting data

Changing date with crtl1 Change date eg. 10-06-2024 to '10-06-2024. Not working with sorting data.
Why and how to avoid?
Best regards
Søren

The cell contained text AND it was formatted as text.
Then you change the formatting. A formatting attribute must not change the value, so the text remains the same. In Excel-ish spreadsheets, a leading apostrophe marks a numeric text or a literal text with a leading equal sign. '00123 enters a 5 digit text. It does does not enter the number one hundred twenty three.

Nobody knows, if your text '10-06-2024 is supposed to mean 5th of October (US American style) or 10th of June (rest of the world). Semi-automatic conversion from text to number may give even more chaos than the dysfunctional text values.

The '10-06-2024 is not a date (not a numeric value). The single quote sign is a flag, meaning: “the cell content is a pure string, it will be handled as a pure string”.

The proper ISO date order: YYYY-MM-DD. All of other used “YearMonthDay” date orders will cause some problems at the import/input the date values, depended on the local settings.

You might find this wiki helpful, Faq/Calc/How to convert number text to numeric data - The Document Foundation Wiki