Consider the following struct definitions, which represent a point on the Cartes
ID: 3632435 • Letter: C
Question
Consider the following struct definitions, which represent a point on the Cartesian plan, and a rectangular region on the Cartesian plane, respectively.struct point {
int x; /* x coordinate */
int y; /* y coordinate */
};
struct rectangle {
struct point bottomLeft;
struct point topRight;
};
Write a function named "sort" that sorts an array of rectangles, smallest to largest. Two rectanges are ordered with each other according to the following rules:
The rectangle with the smaller area is less.
If the areas are the same, then the rectangle that begins further to the left is less.
If the starting x-coordinates are equal, then the rectangle that begins at a lower point is less.
If the starting x- and y-coordinates are equal, then the shorter rectangle is less.
The function takes two arguments: an array of struct rectangle, and the size of the array (an integer).
void sort(struct rectangle *array, int size);
You may define additional functions in your solution.
Please help, Thank you!