170 views
in GUI Development by
How to sort an array of string contains date and time.

1 Answer

0 votes
by

Hello mvg,

Embedded Wizard does not provide such functionality built-in and ready to be use. You will need to implement the sort algorithm and the necessary date/time parsing by yourself. Unfortunately we have no example demonstrating this. Following steps explain how can you do this:

1. The sort algorithm, I imagine, is not difficult. You need a for-loop to iterate over the array content and compare the array items pairwise. Depending on the result of the compare operation you exchange the items or leave them as they are. Then continue with the next pair till the end of the array. This operation you repeat until no more items need to be reordered.

2. More difficult will be the date/time string decoding since there are many different standards to write date/time. In the simplest case, when the date/time notation is well known and fixed, you can separate the string in string fragments for day, month, year, etc. Use the built-in functions like left(), right() or middle(). With the function find() you can search in the string for a particular character or sub-string.

3. Then you can convert the string fragments in numbers by using built-in parse functions (e.g. parse_int32()). Once you have the numbers for day, month, year, etc. you use them to initialize the properties of a Core::Time object. Reading then the property Time of the Core::Time object returns the number of seconds since 1.1.1970 as int64 corresponding to the original date/time. The value can be used in a compare operation (in the sort algorithm above) when you traverse through the array and compare the strings.

I hope it helps you further.

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...