Reverse each element of an array then sort the array in Python

Given an array arr1[] of size n, so firstly we have to reverse each element of an array, and store each of that reversed element in new arr2[] and then sort. Examples: Input : arr1[]={45,67,98,10} Output : after sorting=>{1,54,76,89} Explanation : arr1[]={45,67,98,10} so after reversing each element: arr2[]={54,76,89,1} after sorting arr2[] becomes: arr2={1,54,76,89} Input : arr1[]={20,56,90,19,42,67} Output :… Read More »

Sort an array of string of dates in ascending order

Given an array arr[] of N dates in the form of “dd-mm-yyyy”, the task is to sort these dates in ascending order. Examples: Input: arr[] = { “25-08-1996”, “03-08-1970”, “09-04-1994” } Output: 03-08-1970 09-04-1994 25-08-1996 Input: arr[] = { “14-02-1972”, “01-01-2001”} Output: 14-02-1972 01-01-2001 A simple solution that comes to our mind is to delete all ‘-‘ from… Read More »