C++ program for Sorting Dates using Selection Sort Last Updated : 06 Apr, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report C // C++ program for sorting dates using selection sort #include<bits/stdc++.h> using namespace std; struct date { int day; int month; int year; }; int main() { struct date input[5]; for(int i=0; i<5; i++) { cin>>input[i].day; cin>>input[i].month; cin>>input[i].year; } for (int i=0; i<4; i++) { for (int j=i+1; j<5; j++) { if (input[i].year > input[j].year) { struct date temp = input[i]; input[i] = input[j]; input[j] = temp; } else if (input[i].year == input[j].year && input[i].month > input[j].month) { struct date temp = input[i]; input[i] = input[j]; input[j] = temp; } else if (input[i].year == input[j].year && input[i].month == input[j].month && input[i].day > input[j].day) { struct date temp = input[i]; input[i] = input[j]; input[j] = temp; } } } for(int i=0; i<5; i++) { cout<<input[i].day<<" "<<input[i].month<<" "<<input[i].year; cout<<endl; } } This program is contributed by Dinesh T.P.D. Comment More infoAdvertise with us Next Article Program to sort an array of strings using Selection Sort K kartik Follow Improve Article Tags : Sorting DSA date-time-program Practice Tags : Sorting Similar Reads Program to sort an array of strings using Selection Sort Given an array of strings, sort the array using Selection Sort. Examples: Input : paper true soap floppy flower Output : floppy, flower, paper, soap, true Prerequisite : Selection Sort. C++ // C++ program to implement selection sort for // array of strings. #include <bits/stdc++.h> #include 7 min read Sorting Algorithms Visualization | Selection Sort The human brain can easily process visuals in spite of long codes to understand the algorithms. In this article, Selection Sort visualization has been implemented using graphics.h library. As we all know selection sort first finds the minimum element from the unsorted array and swaps it with the fir 6 min read C Program to Sort an array of names or strings Given an array of strings in which all characters are of the same case, write a C function to sort them alphabetically. The idea is to use qsort() in C and write a comparison function that uses strcmp() to compare two strings. C #include <stdio.h> #include <stdlib.h> #include <string. 2 min read A sorting algorithm that slightly improves on selection sort As we know, selection sort algorithm takes the minimum on every pass on the array, and place it at its correct position.The idea is to take also the maximum on every pass and place it at its correct position. So in every pass, we keep track of both maximum and minimum and array becomes sorted from b 6 min read Insertion sort using C++ STL Implementation of Insertion Sort using STL functions. Pre-requisites : Insertion Sort, std::rotate, std::upper_bound, C++ Iterators. The idea is to use std::upper_bound to find an element making the array unsorted. Then we can rotate the unsorted part so that it ends up sorted. We can traverse the a 1 min read Program for sorting variables of any data type Given an array of any data type, the task is to sort the given array without using in-built sorting functions.Examples:Input: arr[] = [64, 34, 25, 12, 22, 11, 90]Output: 11 12 22 25 34 64 90 Input: arr[] = ["banana", "apple", "orange", "grape", "kiwi"]Output: apple banana grape kiwi orange Input: ar 7 min read Like