Precise sorting of colloidal nanoparticles is a challenging yet necessary task for size-specific applications of nanoparticles in nanophotonics and biochemistry. Here we present a new strategy for all-optical sorting of metal nanoparticles with dynamic and tunable optical driven forces generated by phase gradients of light. Size-dependent optical forces arising from the phase gradients of optical line traps can drive nanoparticles of different sizes with different velocities in solution, leading to their separation along the line traps. By using a sequential combination of optical lines to create differential trapping potentials, we realize precise sorting of silver and gold nanoparticles in the diameter range of 70-150 nm with a resolution down to 10 nm. Separation of the nanoparticles agrees with the analysis of optical forces acting on them and with simulations of their kinetic motions. The results provide new insights into all-optical nanoparticle manipulation and separation and reveal that there is still room to sort smaller nanoparticle with nanometer precision using dynamic phase-gradient forces.