fix sort (off-by-one), use xor swap

omit tmp, use xor swap-inplace instead