In a Document Library I edit one document after filtering or sorting the library. After saving I lose all the filters applied.
How do I keep the filters?
Thats not how they work, they don't remember the last filter/sort selection.
There are 3rd party filter provider web parts that can remember your last filter selection (though this won't help with the sorting, but you can probably do that in the view) :-
(Disclaimer, I work for the first company and there may well be others that can remember the last filter value)
You indicate in other comments that you want to edit say 5 files for each filter group - so alternatively what you could do is open the files in a new tab by right clicking > open in new window/tab or holding down CTRL as you left click - thereby keeping yoru orig window with the filter/sorting open.
Your filters and sorting should be part of view of document library. Select edit this view option and apply your sorts and filters to preserve the options.