Added support of nulls order for reverse order

Order part of query with custom statements like `nulls first` or
`nulls last` at the end which arrange `null` values to top or bottom,
is broken for reverse order sql generation by adding `DESC` at the end,
because of skipping `asc|desc` before `nulls first|last` expression.

Refactored `reverse_sql_order` to take in account,
that there is `nulls` statement after order direction
which are supported by ANSI from 2008.

Closes #11571