def cluster_sort(self, cmp1="<STR_LIT>", cmp2="<STR_LIT>", reversed=False, n=<NUM_LIT:12>):
sorted = self.sort(cmp1)<EOL>clusters = ColorList()<EOL>d = <NUM_LIT:1.0><EOL>i = <NUM_LIT:0><EOL>for j in _range(len(sorted)):<EOL><INDENT>if getattr(sorted[j], cmp1) < d:<EOL><INDENT>clusters.extend(sorted[i:j].sort(cmp2))<EOL>d -= <NUM_LIT:1.0> / n<EOL>i = j<EOL><DEDENT><DEDENT>clusters.extend(sorted[i:].sort(cmp2))<EOL>if reversed: _list.reverse(clusters)<EOL>return clusters<EOL>
Sorts the list by cmp1, then cuts it into n pieces which are sorted by cmp2.

If you want to cluster by hue, use n=12 (since there are 12 primary/secondary hues).
The resulting list will not contain n even slices:
n is used rather to slice up the cmp1 property of the colors,
e.g. cmp1=brightness and n=3 will cluster colors by brightness >= 0.66, 0.33, 0.0