#NEWLINE# def orderingFilter( queryset , querydict , fields ) : #NEWLINE# #INDENT# "\n    Only works if the ordering hasn't already been set. Which it hasn't, but... \n    " #NEWLINE# try : #NEWLINE# #INDENT# ordering = querydict [ 'ordering' ] #NEWLINE# if ( ordering . lstrip ( '-' ) in fields ) : #NEWLINE# #INDENT# orderlist = [ ordering ] #NEWLINE# queryset = queryset . order_by ( * orderlist ) #NEWLINE# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# return queryset