Add sorting functionality to prototype