Return Hue, Saturation, Value string for (colorname, r, g, b).

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

    return H + S + V