Write a function definition of the function sort_dates. This function takes as a
ID: 3859541 • Letter: W
Question
Write a function definition of the function sort_dates. This function takes as an argument the dates array. Your function should sort the elements of the dates array in chronological order from oldest to newest. For example, if dates array is:
The sorted dates array would be:
["03/02/2010", "12/12/2013", "04/27/2015"]
Hint: We would love to just sort the dates array with dates.sort(). Unfortunately, this does
not sort the dates correctly. In the above example this would result in:
This is because sort sorts strings in lexicographical order. However, if you rewrite each element of the dates array in a different way (think about what that way is!) then you can simply use the sort method on the dates array and then rewrite the dates back into the dd/mm/yyyy format.
Explanation / Answer
#include #include int main() { int i, j; char str[10][50], temp[50]; printf("Enter 10 words: "); for(i=0; iRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.