Fixed sorting
Fixed tests and increased perf on pairs sorting