Clicking on an app icon in dock opens the oldest instance (window) rather than the latest I have a few pdf viewer windows (instances) minimized in the dock. When I click on the viewer icon I want to open the one I used last. (Sometimes I minimize a window just for a second to do some quick action on some other app). However, clicking on a deck icon never opens the latest instance. Instead it always opens the first instance, (something which I didn't look at in hours), which just doesn't make sense. How can I change that?

The same problem appears to multiple instances in other apps.
If you minimise a window but have another window from the app still open, clicking on the Dock icon brings the older window to the front because that's the one that's open. If you want the minimised window, click the minimised window in the Dock, not the app icon.