I have searched lot of time for this. I have got some idea about sorting using key parameter.
I have a list of tuple like this. It's got by OpenCV Hough Circle detection.
correctC = [(298, 172, 25), (210, 172, 25), (470, 172, 25), (386, 172, 22), (648, 172, 25), (384, 44, 22), (558, 110, 22), (562, 170, 25), (382, 108, 25), (734, 172, 25), (126, 172, 24), (646, 44, 22), (296, 110, 23), (126, 234, 26), (470, 236, 25), (296, 44, 25), (208, 108, 24), (38, 170, 25), (730, 110, 22), (730, 44, 25), (468, 110, 23), (468, 44, 25), (208, 44, 25), (124, 44, 22), (558, 44, 22), (36, 110, 24), (36, 44, 22), (298, 234, 26), (210, 236, 25), (648, 234, 25), (732, 234, 22), (562, 234, 26), (384, 236, 25), (38, 234, 26), (646, 110, 25), (124, 112, 27)]
It has 3 values. center coordinate(x,y) and radius.
I need to sort all tuples using it's x and y value.
I can do this sorting separately.
xS=sorted(correctC,key=lambda correctC: correctC[0])
This is sort according to x value only.
yS=sorted(correctC,key=lambda correctC: correctC[1])
This is sort according to y value only.
How can I do both(according to x value and y value) using one expression?
I'm using Python 2.7