sorted output according to highest or lowest