@environmentfilter
def do_sort(environment, value, reverse=False, case_sensitive=False, attribute=None):
 if (not case_sensitive):
  def sort_func(item):
   if isinstance(item, basestring):
    item = item.lower()
   return item
 else:
  sort_func = None
 if (attribute is not None):
  getter = make_attrgetter(environment, attribute)
  def sort_func(item, processor=(sort_func or (lambda x: x))):
   return processor(getter(item))
 return sorted(value, key=sort_func, reverse=reverse)

@ environmentfilter def do_sort ( environment , value , reverse = False , case_sensitive = False , attribute = None ) : if ( not case_sensitive ) : def sort_func ( item ) : if isinstance ( item , basestring ) : item = item . lower ( ) return item else : sort_func = None if ( attribute is not None ) : getter = make_attrgetter ( environment , attribute ) def sort_func ( item , processor = ( sort_func or ( lambda x : x ) ) ) : return processor ( getter ( item ) ) return sorted ( value , key = sort_func , reverse = reverse )
sort a sequence .