rect.normalize()

Normalize the rectangle, i.e. make it so that it has non-negative width and height.

If width is less than 0, the function swaps left and right corners and if height is less than 0, the top and bottom corners are swapped.