Let's say I have two lists (containing 2D positions):
pos1 = [100, 400]
pos2 = [200, 300]
Now I want to store the min x and the min y of these positions into min and max:
min_ = [min_x, min_y]
max_ = [max_x, max_y]
# in this case:
min_ = [100, 300]
max_ = [200, 400]
Actually, I am using a code like this:
min_ = []
max_ = []
min_.append(min(pos1[0], pos2[0]))
min_.append(min(pos1[1], pos2[1]))
max_.append(max(pos1[0], pos2[0]))
max_.append(max(pos1[1], pos2[1]))
Is there a more efficient way to do that?
min_x, max_x = sorted(pos1[0], pos2[0]), same fory