sorting direction handling updated