#NEWLINE# def remove_invalid_fields( self , queryset , fields , view ) : #NEWLINE# #INDENT# 'Remove invalid fields from an ordering.\n\n        Overwrites the DRF default remove_invalid_fields method to return\n        both the valid orderings and any invalid orderings.\n        ' #NEWLINE# valid_fields_map = { name : source for ( name , label , source ) in self . get_valid_fields ( fields , view ) } #NEWLINE# valid_orderings = [ ] #NEWLINE# invalid_orderings = [ ] #NEWLINE# for term in fields : #NEWLINE# #INDENT# stripped_term = term . lstrip ( '-' ) #NEWLINE# reverse_sort_term = ( '' if ( len ( stripped_term ) is len ( term ) ) else '-' ) #NEWLINE# if ( stripped_term in valid_fields_map ) : #NEWLINE# #INDENT# name = ( reverse_sort_term + valid_fields_map [ stripped_term ] ) #NEWLINE# valid_orderings . append ( name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# invalid_orderings . append ( term ) #NEWLINE# #UNINDENT# #UNINDENT# return ( valid_orderings , invalid_orderings )