def sortkey(x):
r = x[<NUM_LIT:1>] / <NUM_LIT><EOL>g = x[<NUM_LIT:2>] / <NUM_LIT><EOL>b = x[<NUM_LIT:3>] / <NUM_LIT><EOL>cmax = max(r, g, b)<EOL>V = str(int(round(cmax * <NUM_LIT:100>))).zfill(<NUM_LIT:3>)<EOL>cmin = min(r, g, b)<EOL>delta = cmax - cmin<EOL>if delta == <NUM_LIT:0>:<EOL><INDENT>hue = <NUM_LIT:0><EOL><DEDENT>elif cmax == r:<EOL><INDENT>hue = <NUM_LIT> * (((g - b)/delta) % <NUM_LIT:6>)<EOL><DEDENT>elif cmax == g:<EOL><INDENT>hue = <NUM_LIT> * (((b - r)/delta) + <NUM_LIT:2>)<EOL><DEDENT>else:<EOL><INDENT>hue = <NUM_LIT> * (((r - g)/delta) + <NUM_LIT:4>)<EOL><DEDENT>H = str(int(round(hue))).zfill(<NUM_LIT:3>)<EOL>if cmax == <NUM_LIT:0>:<EOL><INDENT>sat = <NUM_LIT:0><EOL><DEDENT>else:<EOL><INDENT>sat = delta / cmax<EOL><DEDENT>S = str(int(round(sat  * <NUM_LIT:100>))).zfill(<NUM_LIT:3>)<EOL>return H + S + V<EOL>
Return Hue, Saturation, Value string for (colorname, r, g, b).