<s> """<STR_LIT>""" <EOL> from traits . api import HasTraits <EOL> class ViewerSorter ( HasTraits ) : <EOL> """<STR_LIT>""" <EOL> def sort ( self , viewer , parent , elements ) : <EOL> """<STR_LIT>""" <EOL> def comparator ( element_a , element_b ) : <EOL> """<STR_LIT>""" <EOL> return self . compare ( viewer , parent , element_a , element_b ) <EOL> elements . sort ( comparator ) <EOL> return elements <EOL> def compare ( self , viewer , parent , element_a , element_b ) : <EOL> """<STR_LIT>""" <EOL> category_a = self . category ( viewer , parent , element_a ) <EOL> category_b = self . category ( viewer , parent , element_b ) <EOL> if category_a != category_b : <EOL> result = cmp ( category_a , category_b ) <EOL> else : <EOL> if hasattr ( viewer , '<STR_LIT>' ) : <EOL> label_a = viewer . label_provider . get_text ( viewer , element_a ) <EOL> label_b = viewer . label_provider . get_text ( viewer , element_b ) <EOL> else : <EOL> label_a = viewer . node_model . get_text ( viewer , element_a ) <EOL> label_b = viewer . node_model . get_text ( viewer , element_b ) <EOL> result = cmp ( label_a , label_b ) <EOL> return result <EOL> def category ( self , viewer , parent , element ) : <EOL> """<STR_LIT>""" <EOL> return <NUM_LIT:0> <EOL> def is_sorter_trait ( self , element , trait_name ) : <EOL> """<STR_LIT>""" <EOL> return False </s>
