Package schrodinger :: Package structutils :: Module sort :: Class DsuList
[hide private]
[frames] | no frames]

Class DsuList

       object --+                
                |                
    _abcoll.Sized --+            
                    |            
       object --+   |            
                |   |            
 _abcoll.Iterable --+            
                    |            
       object --+   |            
                |   |            
_abcoll.Container --+            
                    |            
     _abcoll.Sequence --+        
                        |        
  _abcoll.MutableSequence --+    
                            |    
            UserList.UserList --+
                                |
                               DsuList

A class to sort a list with special behaviors. The list is expected to be a Decorate-Sort-Undecorate list, e.g. a sequence of tuples with the same length. The class has data members to control sort order, asending or descending, and can place None values after defined values.

Nested Classes [hide private]

Inherited from _abcoll.Sized: __metaclass__

Instance Methods [hide private]
 
__init__(self, init_list=None, item_order=None, none_is_last=True)
init_list (list of tuples) A list of tuples to be sorted.
 
_sort(self, sequence_1, sequence_2)
Custom sort function that imitates native python lexicographical list sorting but allows item level control over sort order, and can optionally place None values at the end of a list.
 
_cmp(self, value_1, value_2, order=1)
Custom item comparison method that applies policy to item order and handles None values according to the 'none_is_last' attribute.

Inherited from UserList.UserList: __add__, __cmp__, __contains__, __delitem__, __delslice__, __eq__, __ge__, __getitem__, __getslice__, __gt__, __iadd__, __imul__, __le__, __len__, __lt__, __mul__, __ne__, __radd__, __repr__, __rmul__, __setitem__, __setslice__, append, count, extend, index, insert, pop, remove, reverse, sort

Inherited from _abcoll.Sequence: __iter__, __reversed__

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

Class Methods [hide private]

Inherited from _abcoll.Sized: __subclasshook__

Class Variables [hide private]

Inherited from UserList.UserList: __abstractmethods__, __hash__

Inherited from UserList.UserList (private): _abc_cache, _abc_negative_cache_version, _abc_registry

Inherited from _abcoll.Sized (private): _abc_negative_cache

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, init_list=None, item_order=None, none_is_last=True)
(Constructor)

 

init_list (list of tuples)
    A list of tuples to be sorted.  Tuples to sort also can be added
    via the 'append()' method.  The tuples are sorted according to the
    first item in each tuple, ties are broken by sorting by the second
    item, etc.

item_order (list of ints)
    Optional list of integers indicating whether specifying ascending
    or descending sort order for the tuple items.  A positive value at
    the same index of a tuple item will cause those items in the list
    to be sorted in ascending order.  A negative value at the same
    index will cause those items to be sorted in descending order.
    Default is to sort in ascending order.

none_is_last (bool)
    If True then None values are placed after defined values,
    which matches the behavior in Maestro or Excel, but is
    not pythonic.

Overrides: object.__init__

_sort(self, sequence_1, sequence_2)

 

Custom sort function that imitates native python lexicographical
list sorting but allows item level control over sort order,
and can optionally place None values at the end of a list.

sequence_1 (sequence)
    Sequence that emits items to be compared.

sequence_2 (sequence)
    Sequence that emits items to be compared, of the same type
    as sequence_1,

_cmp(self, value_1, value_2, order=1)

 

Custom item comparison method that applies policy to item order and
handles None values according to the 'none_is_last' attribute.

value_1
value_2
    The two values being compared.

order
    Optional sort order.  Default is ASCENDING.