added sort_eigenpairs function and used it