Note that there are cases when it makes sense to not reset to the page one—when there's a notion of the ‘current selected’ or focused item in the list. Examples are mostly desktop apps with emphasis on immediate user interaction in the list itself with the help of the concept of ‘focus,’ instead of jumping between views like in web apps:
a file manager that ...
A sort order change should lead to a page reset (to one) when nothing is selected in the results list. The user has not yet shown specific interest in a particular entry.
If, however, there is a selection (especially in lists that have a master-detail view), it is likely the user wants to see "what is around the selected entry" - In this case, the page ...
I am a back-end programmer and not UI expert at all
Let say data shown in your screenshot is is sorted to Oldest First and user is on page 20
Then user thinks he wants to see newest items, so he selects Newest First, if you keep him on page 20, will he see the newest on page 20? NO
In short, pagination should be reset upon change of order
There would be a weak case for not resetting it:
User wants random samples that avoid being at the extremes of any sort order.
This certainly does not make a good default, but might be useful if selectable as an option.
If changing the sort direction while not changing the criterium, browsing to the page that has the most of the items that were visible ...
Order of data transformation
As explained in Sorting a Paginated Record Set User Experience Expectation, and as illustrated there by the following order of data transformations:
You can see that both filtering and sorting come before pagination.
This means that whenever the order changes (sort), you should repaginate.
Back to page one?
Whether or not ...
Keeping the page number after changing the order makes no sense. The page number is the same but the page isn't, let alone that going back or forth between pages lost the idea of coordination. What use would that have for the user? If you test this on real users you can expect them to be confused by this. They probably expect to see the first result on page ...