cf.Field.sort

Field.sort(cmp=None, key=None, reverse=False)[source]

Sort the field, viewed as a single element field list, in place.

Note that f.sort(cmp, key, reverse) is equivalent to f, thus providing compatiblity with a single element field list.

New in version 1.0.4.

Examples 1:
>>> f.sort()
Parameters:
cmp : function, optional

Specifies a custom comparison function of two arguments (iterable elements) which should return a negative, zero or positive number depending on whether the first argument is considered smaller than, equal to, or larger than the second argument. The default value is None.

Example:

cmp=lambda x,y: cmp(x.lower(), y.lower()).

key : function, optional

Specifies a function of one argument that is used to extract a comparison key from each list element. The default value is None (compare the elements directly).

Example:

key=str.lower.

reverse : bool, optional

If set to True, then the list elements are sorted as if each comparison were reversed.

Returns:

None

Examples 2:
>>> id0 = id(f)
>>> f.sort()
>>> id0 == id(f)
True
>>> g = cf.FieldList(f)
>>> id0 = id(g)
>>> g.sort()
>>> id0 == id(g)
True