Implement next_lexicographic and prev_lexicographic:wq
fixed whitespaces
fixed formatting and added tests
Merge pull request #2059 from shravas/implement_prev_lexicographic

Implement prev_lexicographic and next_lexicographic
pass along flag in xreplace