Example 87: Sort Dates

Learn how to sort dates using structures.

Problem

Write a function to sort the date of births of the employees in ascending order stored in an array of structures.

The structure for employees with the following attributes has been created for you.

  • Employee name as emp_name
  • Date of birth as date
  • Month of birth as month
  • Year of birth as year

Example

Input Output
Rahul, 19, 11, 1992
Sameer, 24, 6, 1991
Prashant, 22, 11, 1993
Soujanya, 12, 12, 1992
Sarmishta, 14, 10, 1992
Prashant 22.11.1993
Soujanya 12.12.1992
Rahul 19.11.1992
Sarmishta 14.10.1992
Sameer 24.6.1991

Try it yourself

Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.

Note: You do not need to change the printEmployees() function or call this function. It has been done for you.

Get hands-on with 1400+ tech skills courses.