Remember form data for pagination
You can use url parameters to pass the info about sorting. Say user selects sorting by name. Then add this at the end of url
your_url?sort=name
Then you can access it as
value = request.args.get('name','')
Simply pass sorting variable value to the template where you append sort value to the next url.
Edit:
To create such url in Flask, do this:
url_for('url_view_name', sort='name')
This will return the url with sort appended as query argument. Check out the flask documentation here to know more about url building
You could do this with Javascript. Since the page number is part of your URL, you could have javascript change the action
of the form that changes pages to submit to a URL with the desired page number instead of the current page.
Just to clarify, when the user clicks the "next" link/button or page number, use Javascript to change the action of the html form so that it posts the form to the desired page instead of the current page.