def sort_root_accounts(roots):
 def compare_roots(a, b):
  if ((a.report_type != b.report_type) and (a.report_type == u'Balance Sheet')):
   return (-1)
  if ((a.root_type != b.root_type) and (a.root_type == u'Asset')):
   return (-1)
  if ((a.root_type == u'Liability') and (b.root_type == u'Equity')):
   return (-1)
  if ((a.root_type == u'Income') and (b.root_type == u'Expense')):
   return (-1)
  return 1
 roots.sort(compare_roots)

def sort_root_accounts ( roots ) : def compare_roots ( a , b ) : if ( ( a . report_type != b . report_type ) and ( a . report_type == u'Balance Sheet' ) ) : return ( - 1 ) if ( ( a . root_type != b . root_type ) and ( a . root_type == u'Asset' ) ) : return ( - 1 ) if ( ( a . root_type == u'Liability' ) and ( b . root_type == u'Equity' ) ) : return ( - 1 ) if ( ( a . root_type == u'Income' ) and ( b . root_type == u'Expense' ) ) : return ( - 1 ) return 1 roots . sort ( compare_roots )
sort root types as asset .