nuts_and_bolts: quicksort for nuts and bolts matching problem