Package muntjac :: Package data :: Package util :: Module default_item_sorter :: Class DefaultItemSorter
[hide private]
[frames] | no frames]

Class DefaultItemSorter

source code

             object --+    
                      |    
item_sorter.IItemSorter --+
                          |
                         DefaultItemSorter

Provides a default implementation of an IItemSorter. The DefaultItemSorter adheres to the ISortable.sort rules and sorts the container according to the properties given using setSortProperties.

A Comparator is used for comparing the individual Property values. The comparator can be set using the constructor. If no comparator is provided a default comparator is used.

Instance Methods [hide private]
 
__init__(self, propertyValueComparator=None)
Constructs a DefaultItemSorter which uses the Comparator indicated by the propertyValueComparator parameter for comparing Property values.
source code
 
__call__(self, o1, o2) source code
 
compare(self, o1, o2)
Compares its two arguments for order.
source code
 
compareProperty(self, propertyId, sortDirection, item1, item2)
Compares the property indicated by propertyId in the items indicated by item1 and item2 for order.
source code
 
setSortProperties(self, container, propertyId, ascending)
Sets the parameters for an upcoming sort operation.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, propertyValueComparator=None)
(Constructor)

source code 

Constructs a DefaultItemSorter which uses the Comparator indicated by the propertyValueComparator parameter for comparing Property values. Uses the default Comparator for comparing Property values if propertyValueComparator is None.

Parameters:
  • propertyValueComparator - The comparator to use when comparing individual Property values
Overrides: object.__init__

compare(self, o1, o2)

source code 

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The parameters for the IItemSorter compare() method must always be item ids which exist in the container set using setSortProperties.

Overrides: item_sorter.IItemSorter.compare
(inherited documentation)

compareProperty(self, propertyId, sortDirection, item1, item2)

source code 

Compares the property indicated by propertyId in the items indicated by item1 and item2 for order. Returns a negative integer, zero, or a positive integer as the property value in the first item is less than, equal to, or greater than the property value in the second item. If the sortDirection is false the returned value is negated.

The comparator set for this DefaultItemSorter is used for comparing the two property values.

Parameters:
  • propertyId - The property id for the property that is used for comparison.
  • sortDirection - The direction of the sort. A false value negates the result.
  • item1 - The first item to compare.
  • item2 - The second item to compare.
Returns:
a negative, zero, or positive integer if the property value in the first item is less than, equal to, or greater than the property value in the second item. Negated if sortDirection is false.

setSortProperties(self, container, propertyId, ascending)

source code 

Sets the parameters for an upcoming sort operation. The parameters determine what container to sort and how the IItemSorter sorts the container.

Parameters:
  • container - The container that will be sorted. The container must contain the propertyIds given in the propertyId parameter.
  • propertyId - The property ids used for sorting. The property ids must exist in the container and should only be used if they are also sortable, i.e include in the collection returned by container.getSortableContainerPropertyIds(). See ISortable.sort for more information.
  • ascending - Sorting order flags for each property id. See ISortable.sort for more information.
Overrides: item_sorter.IItemSorter.setSortProperties
(inherited documentation)